fix: storybook load error#6954
Conversation
WalkthroughPreloads the Storybook module in index.js and changes AppRegistry.registerComponent to return the dynamic module's default export or fall back to the preloaded StorybookModule using the nullish coalescing operator when Storybook is enabled. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@index.js`:
- Around line 8-11: StorybookModule is being required unconditionally at module
load, which forces a devDependency into production; move the
require('./.rnstorybook/index') call inside the if (process.env.USE_STORYBOOK)
block and assign it to a local variable (e.g., StorybookModule) there so
AppRegistry.registerComponent(appName, () => StorybookModule.default ??
StorybookModule) only references the module when USE_STORYBOOK is truthy; keep
the fallback to .default unchanged.
Proposed changes
added fallback for the storybook import
Issue(s)
closes #6953
How to test or reproduce
yarn storybook:startyarn iosScreenshots
Types of changes
Checklist
Further comments
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.