Skip to content

fix: storybook load error#6954

Open
divyanshu-patil wants to merge 2 commits intoRocketChat:developfrom
divyanshu-patil:fix/storybook_fail
Open

fix: storybook load error#6954
divyanshu-patil wants to merge 2 commits intoRocketChat:developfrom
divyanshu-patil:fix/storybook_fail

Conversation

@divyanshu-patil
Copy link

@divyanshu-patil divyanshu-patil commented Jan 29, 2026

Proposed changes

added fallback for the storybook import

Issue(s)

closes #6953

How to test or reproduce

  1. run yarn storybook:start
  2. let app run
  3. stop the server
  4. run yarn ios
  5. wait for build to complete

Screenshots

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

Summary by CodeRabbit

  • Chores
    • Improved Storybook loading reliability by adding a fallback initialization path to prevent startup failures when the primary story export is unavailable.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

Walkthrough

Preloads 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

Cohort / File(s) Summary
Storybook Module Initialization
index.js
Introduce a preloaded StorybookModule via require('./.rnstorybook/index') and update AppRegistry.registerComponent(appName, ...) to register () => require('./.rnstorybook/index').default ?? StorybookModule, providing a fallback if the dynamic default export is missing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped to the index with a curious tune,
I preloaded a module beneath the moon,
If default's gone astray, I won't dismay,
A cozy fallback will save the day! 📦✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: storybook load error' directly addresses the main change in the pull request—fixing a Storybook load error by adding a fallback for the storybook import.
Linked Issues check ✅ Passed The pull request adds a fallback for the storybook import to prevent load errors when Storybook is not running, directly addressing issue #6953's requirement to prevent app startup errors after stopping Storybook.
Out of Scope Changes check ✅ Passed All changes in index.js are scoped to fixing the Storybook load error as specified in the linked issue; no out-of-scope modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: error while starting app after running storybook

1 participant