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.

React Native Server example with storybook 5

See original GitHub issue

I’ve spent the past couple of days trying to get sb5 server running, but I end with a page without any stories populated. Only the device addons work. I’ve downgraded and upgraded using past issues as reference, but I’m still not seeing anything. I tried again today using version 5.1.0-alpha.36 which is set on all @storybook/* packages, cleared cache and reinstalled. No luck. I’m also using the migration guide to set these up. https://github.com/storybooks/storybook/blob/next/MIGRATION.md#react-native-server

Is it possible someone could add a react native example that includes the server feature? It shouldn’t take more than 10 minutes, and it should help newcomers save hours spent on trying to get it to work. That would be much appreciated. Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:38 (27 by maintainers)

github_iconTop GitHub Comments

19reactions
sirsavarycommented, Jul 16, 2019

Chiming in to say I’m experiencing the same issue. Created a new project using Expo v2.12.2 and Storybook v5.2.0-beta.0. I have tried with both a physical device and a simulator. What I’ve noticed is that I can’t seem to access the Storybook server over the network, e.g. navigating to 192.168.0.x:7007 in my phone’s browser shows nothing

That being said, I can access the Expo server from my phone so it’s not an issue with my network/PC. I’m going to make the assumption that Storybook is only permitting connections from localhost.

…and this is exactly the case. Workaround for anyone who stumbles upon this:

  1. Modify your start-storybook command to include -h 0.0.0.0 or if you’re worried about security, use -h [your local IP], where local IP is usually going to be something in the form of 192.168.0.x
  2. Update “storybook/index.js” and change const StorybookUIRoot = getStorybookUI({host: "[IP used with -h]"});
  3. Fire up react-native/expo and Storybook server
  4. Test that your phone/simulator can access [IP used]:7007 in its browser
  5. Opening your RN app should now load the stories back on your PC

Note that these instructions assume you’re using the default port (which in my case is 7007). If you’re using a custom port, you’ll need to update getStoryBookUI to use it.

4reactions
betoharrescommented, Jul 22, 2019

@Gongreg There are no error msgs on console. PFA the emulator / server / web-server Screenshot 2019-07-16 at 1 32 04 PM

If you see this error at the end of the log:

adb: error: cannot bind listener: Operation not permitted

It’s because adb is requesting root access, so you’ll need to to run these two commands:

adb kill-server
adb root

Try to to add the storybook port at the build command, like so:

react-native run-android --port=7007

make sure this error did not appeared:

adb: error: cannot bind listener: Operation not permitted

If that doesn’t work, you can try running:

adb reverse tcp:7007 tcp:7007

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Top 5 @storybook/react-native Code Examples - Snyk
To help you get started, we've selected a few @storybook/react-native examples, based on popular ways it is used in public projects.
Read more >
@storybook/react-native-server | Yarn - Package Manager
With Storybook for React Native you can design and develop individual React Native components without running your app. For more information visit: storybook.js ......
Read more >
Storybook for React Native tutorial - js
During Storybook's install process, you'll be prompted to install react-native-server, do so as this package will help out immensely throughout the tutorial ......
Read more >
@storybook/react-native - npm
OndeviceUI and React native Server ... The react native storybook is designed to be flexible so that you can navigate all your stories...
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 Hashnode Post

No results found