react-16

SSR: dynamic import in react app how to deal with html miss match when component is loading on the client

梦想与她 提交于 2019-12-04 04:21:17
问题 I'm just starting on server side rendering a react 16 app using code splitting and dynamic import thanks to webpack 4 and react-loadable. My question might sound stupid but there's something I don't quite get. On the server side, I'm waiting that webpack has loaded all modules before spitting out the html to the client. On the client side I have a kind of loading component rendered, before rendering the loaded component. So basically the server renders the loaded component: <div>loaded

React Router with React 16.6 Suspense “Invalid prop `component` of type `object` supplied to `Route`, expected `function`.”

十年热恋 提交于 2019-12-03 16:26:53
问题 I'm using the latest version (16.6) of React with react-router (4.3.1) and trying to use code splitting using React.Suspense . Although my routing is working and the code did split into several bundles loaded dynamically, I'm getting a warning about not returning a function, but an object to Route . My code: import React, { lazy, Suspense } from 'react'; import { Switch, Route, withRouter } from 'react-router-dom'; import Loading from 'common/Loading'; const Prime = lazy(() => import('modules