Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Before
- import OtherComponent from './OtherComponent';
- function MyComponent() {
- return (
- <div>
- <OtherComponent />
- </div>
- );
- }
- // After
- const OtherComponent = React.lazy(() => import('./OtherComponent'));
- function MyComponent() {
- return (
- <div>
- <Suspense fallback={<div>Loading...</div>}>
- <OtherComponent />
- </Suspense>
- </div>
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement