react-native: Error: Couldn't find story matching '' after HMR
Describe the bug
During HMR, we get a Error: Couldn't find story matching '' after HMR error in the console
To Reproduce Steps to reproduce the behavior:
- Follow doc instructions to create a sample storybook react-native app
- Add
require("./.ondevice").default;to App.tsx. This mimics an app setup where Storybook is used as a secondary screen/component rather than the main app - Edit a tsx file in the project, and let HMR happen
- Observe the error
Expected behavior No error
Screenshots
ERROR Unable to load story '':
ERROR [Error: Couldn't find story matching '' after HMR.
- Did you remove it from your CSF file?
- Are you sure a story with that id exists?
- Please check your stories field of your main.js config.
- Also check the browser console and terminal for error messages.]
LOG [Error: Couldn't find story matching '' after HMR.
- Did you remove it from your CSF file?
- Are you sure a story with that id exists?
- Please check your stories field of your main.js config.
- Also check the browser console and terminal for error messages.]
Code snippets If applicable, add code samples to help explain your problem.
System:
Please paste the results of npx -p @storybook/cli@next sb info here.
Additional context
This seems to be caused by this line https://github.com/storybookjs/react-native/blob/next/packages/react-native/src/preview/start.tsx#L56 which loads a story with story ID = ''. Because the storybook UI isn’t open in this scenario, the story loading code breaks trying to load a story with id ''. Changing this line to selection: null seems to solve the problem.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 2
- Comments: 27 (12 by maintainers)
Commits related to this issue
- fix: Couldn't find story matching '' after HMR #459 — committed to storybookjs/react-native by dannyhw a year ago
fix released in version 6.5.4
@arthuralee can you try updating and removing the patch?
@LaurensUP oops! I guess I need to update that readme, thanks for pointing it out 🙏