code-splitting

Code splitting/react-loadable issue

泪湿孤枕 提交于 2021-02-18 22:10:29
问题 I'm trying to introduce code splitting into my app using react-loadable. I tried it on a very simple component: const LoadableComponent = Loadable({ loader: () => import('components/Shared/Logo/Logo'), loading: <div>loading</div>, }); However, when this component is rendered, I get the following error: Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of

Wait for CSS to load before JS in React [FOUC]

情到浓时终转凉″ 提交于 2021-02-18 05:13:54
问题 We are building our new website entirely in React and utilizing code-splitting & scss. Whenever a new page is requested it loads the raw HTML in the browser first and then a split second or so later the css styling comes in, seems to be a FOUC issue. This makes for a terrible experience and we need to figure out how to ensure the CSS is loaded before rendering the component(s). Does anyone have any experience with this? There seems to be a lack of information online currently with this issue.

Wait for CSS to load before JS in React [FOUC]

纵然是瞬间 提交于 2021-02-18 05:13:37
问题 We are building our new website entirely in React and utilizing code-splitting & scss. Whenever a new page is requested it loads the raw HTML in the browser first and then a split second or so later the css styling comes in, seems to be a FOUC issue. This makes for a terrible experience and we need to figure out how to ensure the CSS is loaded before rendering the component(s). Does anyone have any experience with this? There seems to be a lack of information online currently with this issue.

Wepback. Loading chunk failed after using `import()`

坚强是说给别人听的谎言 提交于 2021-02-08 05:00:23
问题 I'm working on React project and I had found out that one of budles files is too big and I need to split it. So, I tried to use import() sintax: import React from 'react'; import thumbnails from './thumbnails.json'; export default class Portfolio extends React.Component { constructor(props) { super(props); import('react-image-gallery').then(module => { const ImageGallery = module.default; this.galleries = thumbnails.map((thumbnail, i) => { let items = []; for (let i = 0; i < thumbnail.gallery

React router base code-splitting (get first chunk and then get other chunks async in background)

不羁的心 提交于 2021-01-27 19:56:08
问题 I am using create-react-app. I want to react-router base code-splitting but I want to get the first chunk which user open in browser and then get other chunks asynchronously in the background Routes const HomeModule = React.lazy(() => import('./modules/ft_home_module/src/main')); const AuthModule = React.lazy(() => import('./modules/ft_auth_module/src/main')); const ProfileModule = React.lazy(() => import('./modules/ft_profile_module/src/main')); const MerchantModule = React.lazy(() => import

React.lazy and prefetching components

若如初见. 提交于 2020-12-04 09:04:45
问题 I have a 2 step Application Flow that looks like this: const Step1 = React.lazy(() => import('./Step1')); const Step1 = React.lazy(() => import('./Step2')); <Suspense fallback={<Loading />}> <Route path="/step1" render={() => <Step1 />} /> <Route path="/step2" render={() => <Step2 />} /> </Suspense> Using React.lazy, I can defer loading <Step2 /> while the user is on <Step1 /> , which can improve initial page load. However, I would like to prefetch <Step2 /> while the user is on <Step1 /> as

React.lazy not working in production mode

 ̄綄美尐妖づ 提交于 2020-07-08 06:14:41
问题 I have a react app running, and I wanted to add route based code-splitting using React.lazy to it. Currently my code is, import { PureComponent, cloneElement, Suspense, lazy } from 'react'; ... export const CartPage = lazy(() => import(/* webpackMode: "lazy", webpackPrefetch: true */ 'Route/CartPage')); ... <Suspense fallback={ this.renderFallbackPage() }> <NoMatchHandler> <Switch> ... <Route path="/cart" exact component={ CartPage } /> ... </Switch> </NoMatchHandler> </Suspense> Only