Closed kd4001 closed 4 years ago
React Error Boundaries require class component, there's no official hook for this feature at the moment, but I guess you can use this package : https://www.npmjs.com/package/use-error-boundary
Warning : This package (bs-dynamic-import) is now in read-only mode, if you want to lazy load React components in a ReasonML application use "reason-loadable".
If you want to import something else like a JSON document or JavaScript code that isn't a React component (example : Math library), take a look at "reason-loadable" source code and tests, it can do that with some adaptation.
This package (bs-dynamic-import) probably doesn't work anymore since BuckleScript changed object representation in JavaScript output in recent version (from array to object).
In React we can handle this by React Error Boundaries. https://reactjs.org/docs/error-boundaries.html
Something similar can be done here too to catch the error if any chunk fails.