Caching is a way of storing data, usually through cookies on a website, which leads to better performing websites.
On a website things like images and log in details may be cached. This means that when you next visit that website, it will not have to download this data again.
If youβre using create-react-app
, there is some caching in the form of a Service Worker for rendering the app.
You want to use the hydate method
instead of render.
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.hydrate(<App />, document.getElementById('root'));
const Example = React.Lazy(() => import('./Example))
<Suspense fallback={<p>Loading</p>}>
<Example />
</Suspense>
const Example = React.lazy(() => import('./Example))
...
<Router>
<Suspense fallback={"Loading"}>
<Switch>
<Route path='/' component={Example} />
</Switch>
</Suspense>
</Router>