Open dwjohnston opened 1 year ago
Hi @shilman @dwjohnston I have re-generated your issue. below are my findings :
Attaching Below the Screenshot of the updated Output on Chrome :
@dwjohnston I am creating a pull request in your repository. Request you to merge it.
@pratyushvatsalshukla Have addressed your PR here. The repo linked intentionally creates a runtime error so that we can observe the behaviour of thrown errors/error boundaries in CRA + Storybook.
Describe the bug
I have a component like this:
Where that
SomeComponentInner
will throw an error at render time.So the expected (and actual behaviour for non CRA storybook configurations) behaviour is in Storybook the render error is thrown and the error boundary is displayed.
However, in a Storybook configuration for create-react-app we instead see this overlay error:
We can click that close button, and see the error boundary.
However, this is a jarring experience. Also, it will be detected as an error by @storybook/test-runner.
To Reproduce
Repro for this here:
https://github.com/dwjohnston/storybook-cra/commit/7e68e968343851db8ad0604c5f9cb3100a7608cf
This is a basic create app application generated with:
Run
yarn storybook
and navigate to the Errored example.System
Additional context
It appears that the overlay comes from this package:
https://github.com/pmmmwh/react-refresh-webpack-plugin
This behaviour can be solved by adding this to your storybook config in
.storybook/main.js
Though this solution is a bit hamfisted - there are plenty of other cases where we do want to see the error overlay - ie. when we're not using an error boundary.
Also, this will still be detected as an error by @storybook/test-runner