Storybook is a great tool for working on UI in isolation. Generally all UI should have a storybook file so it can easily be updated and it's a great way to break up a feature into smaller PRs.
Storybook uses the same entry point as our main app (index.js), so you'll need to temporarily modify the entry point to run Storybook.
-
Modify the entry point - Open
index.jsin the project root -
Enable Storybook imports - Uncomment the following lines:
import Storybook from './.storybook'; AppRegistry.registerComponent(name, () => Storybook);
-
Disable the regular app registration - Comment out the following lines:
// AppRegistry.registerComponent(name, () => // // Disable Sentry for E2E tests // isE2E ? Root : Sentry.wrap(Root), // );
-
Run the app - Start the app as you normally would
-
View Storybook - The app will now launch with the Storybook UI instead of the regular app
Whenever you add, remove, or move *.stories.* files, regenerate Storybook's requires list:
yarn storybook-generateThis ensures Storybook picks up all stories correctly in the app.
When you're done with Storybook:
-
Re-comment the Storybook imports:
// import Storybook from './.storybook'; // AppRegistry.registerComponent(name, () => Storybook);
-
Uncomment the regular app registration:
AppRegistry.registerComponent(name, () => // Disable Sentry for E2E tests isE2E ? Root : Sentry.wrap(Root), );
Note: Make sure not to commit these changes to
index.jsas they are only for local development with Storybook.