question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to set up React Native Storybook with alternate dist directory (e.g. with TypeScript)?

See original GitHub issue

The default installation instructions create a ./storybook directory, but in our case we need all source to be in src for TypeScript. We compile to dist.

Moving storybook directory to src and compiling it doesn’t appear to work. We can get the server running with -c dist/storybook, but then the app runs normally - not showing any storybook content.

How can we get the storybook app to run with react-native run-ios when it’s in the ./dist/storybook directory?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Hypnosphicommented, Sep 28, 2017

@lukecwilliams it’s used for dealing with HMR

1reaction
lukewlmscommented, Sep 28, 2017

@roblafeve So far I don’t have a better answer for (1) above - I just have to modify jsBundleURLForBundleRoot.

Here’s what else I had to do to get running with storybook/RN/TS:

  • Moved storybook files to ./src/storybook, and compiling to ./dist/storybook along with other code
  • Had to add declarations like this to satisfy TS (is there a better answer?) declare var module: {};
  • Modified package.json script with directory: “storybook”: “storybook start -p 7007 -c dist/storybook”
  • I’ll have to remember to delete the ./dist/storybook directory prior to production deployment

I’d still really like to know how to get storybook to find my index.ios.js file without my having to make temporary modifications to AppDelegate.m - I believe Storybook is supposed to be able to just find this file when the storybook packager is running!


(Side note: I was unable to get output to multiple directories with multiple tsconfig.json files in different folders, though comments elsewhere seemed to indicate this is possible. Although this would mean no danger of accidentally shipping ./dist/storybook directory, I think this would not actually help because AppDelegate.m is still pointing to dist for the entry file so wouldn’t find it.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set up React Native Storybook with alternate dist ...
The default installation instructions create a ./storybook directory, but in our case we need all source to be in src for TypeScript.
Read more >
Setting up Storybook for React Native/TypeScript (server ...
Step 1: Install Storybook · Step 2: Conditionally render Storybook · Step 3: Boot Storybook · Step 4: Take care of asyncStorage warning...
Read more >
Creating a React Component Library using Rollup, Typescript ...
js within the same directory. Now by running npm run build you should see Rollup do it's thing and create a /build folder...
Read more >
Configure Storybook
Storybook is configured via a folder called .storybook , which contains various configuration files. Note that you can change the folder that Storybook...
Read more >
How to structure your project and manage static resources in ...
In React Native, we often need to implement a button with an image background in many screens. Here is a simple one that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found