Solution for this issue is available when using React.lazy:
- https://www.codemzy.com/blog/fix-chunkloaderror-react
- https://raphael-leger.medium.com/react-webpack-chunkloaderror-loading-chunk-x-failed-ac385bd110e0
However we are using @loadable/component and it is less clear how we can resolve these ChunkLoadError's when using this module. We just recently started code-splitting in our application, and the headache from these errors has been offsetting any performance gain our web application has gotten.
How can we prevent ChunkLoadError's when using @loadable/component?
The reason we were using
@loadable/componentin the first place is for the.preload()function. However, until we can resolve this ChunkLoadError issue, we are going to stop using@loadable/component.We've installed https://www.npmjs.com/package/react-lazy-with-preload and followed the exact solution in the medium post above, except we used
lazyWithPreloadinstead oflazywithin thelazyWithRetryfunction.We can then load components as such in our App.js file:
I am hopeful that this solution handles all 3 of:
LoadChunkErrorsfingers crossed that this works...