million
million copied to clipboard
feat: Error boundaries
https://github.com/aidenybai/million-react/issues/6
FYI, preact implements a useErrorBoundary
to catch error during rendering: https://preactjs.com/guide/v10/hooks/#useerrorboundary
https://github.com/preactjs/preact/blob/0406941612c12f1056e9f1f00c62030c591dd085/hooks/src/index.js#L319
However, preact still implements it based on componentDidCatch
.
It is possible to implement a similar solution, but it won't be a drop-in replacement for react.
I did a very basic PoC that adds componentDidCatch
to class components from errors caught on render
.
I'm not sure if adding a useErrorBoundary
hook makes sense for Million? (And not sure if it’s currently possible, will have to dig a bit more)