Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React-Native: Fresh install doesn't show storybook elements (Android Only!) #1567

Closed
Billydubb opened this issue Aug 1, 2017 · 13 comments
Closed

Comments

@Billydubb
Copy link
Contributor

Billydubb commented Aug 1, 2017

I am using npm version: 3.10.8, node version 6.9.0 and @storybook/cli and getstorybook version 3.1.9

On a fresh react-native init project I install storybook by running getstorybook in the directory.

The install completes fine and the storybook directory is created inside my project root directory.

Now I start storybook with npm run storybook
The site is set up at localhost:7007 correctly, but none of the stories in the storybooks/stories directory show up in the left panel plus I get 2 warnings in the console:

Warning: Stateless function components cannot be given refs. Attempts to access this ref will fail.

Check the render method of `Container(LeftPanel)`.
    in LeftPanel (created by Container(LeftPanel))
    in Container(LeftPanel) (created by Layout)
    in div (created by Layout)
    in div (created by Layout)
    in div (created by Pane)
    in Pane (created by SplitPane)
    in div (created by SplitPane)
    in SplitPane (created by Layout)
    in div (created by Layout)
    in Layout (created by Container(Layout))
    in Container(Layout)
    in div

Warning: Stateless function components cannot be given refs. Attempts to access this ref will fail.

Check the render method of `Container(ShortcutsHelp)`.
    in ShortcutsHelp (created by Container(ShortcutsHelp))
    in Container(ShortcutsHelp)
    in div

According to the documentation here I am not supposed to run: react-native run-android to see the stories on my device or emulator. However, that gives me an error in the emulator saying 'websocket: connection error', 'Failed to connect to localhost/127.0.0.1:7007'

@shilman
Copy link
Member

shilman commented Aug 1, 2017

@Billydubb it's a little wonky. What's supposed to happen is that:

  1. You run storybook and open it in http://localhost:7007
  2. You shouldn't see any stories to start out
  3. You run it on your device and it connects to the storybook server on localhost:7007
  4. The stories show up in the browser, and on your device

Let me know if that works for you?

@Billydubb
Copy link
Contributor Author

At step 3. I get the error 'websocket: connection error', 'Failed to connect to localhost/127.0.0.1:7007'.
screen shot 2017-08-03 at 7 48 04 pm

@Billydubb
Copy link
Contributor Author

I just tried the same sequence of steps on iOS and there it works without a problem. This seems to be somehow Android related.

@Billydubb Billydubb changed the title React-Native: Fresh install doesn't show storybook elements React-Native: Fresh install doesn't show storybook elements (Android Only!) Aug 3, 2017
@Billydubb
Copy link
Contributor Author

Got help in the storybooks slack channel.

After step 3 you have to run
adb reverse tcp:7007 tcp:7007
to route any traffic to the 7007 port on the emulator to the 7007 port on the local machine.

@Gongreg
Copy link
Member

Gongreg commented Aug 11, 2017

@Billydubb, I got into the same issue today. Maybe it would be nice to write about this somewhere in readme?

@Billydubb
Copy link
Contributor Author

Billydubb commented Aug 11, 2017

I already did add it to the readme:

"If you are using Android and you get the following error after running the app: 'websocket: connection error', 'Failed to connect to localhost/127.0.0.1:7007', you have to forward the port 7007 on your device/emulator to port 7007 on your local machine with the following command: adb reverse tcp:7007 tcp:7007

@Gongreg
Copy link
Member

Gongreg commented Aug 11, 2017

@Billydubb Awesome! :) I will close the issue then.

@pashute
Copy link

pashute commented Jun 20, 2018

where do I write that "following command" of adb ...?

@Billydubb
Copy link
Contributor Author

@pashute In the terminal

@pashute
Copy link

pashute commented Jun 20, 2018

My problem was that I was running yarn start storybook instead of yarn run storybook.

@amed
Copy link

amed commented Aug 16, 2018

I am facing the same issue, getstorybook is installing react configurations, even the app is react-native.
The app is created by $ react-native init

"react": "16.3.1",
"react-native": "0.55.4"

maybe I am holding it wrong 😮

@Billydubb
Copy link
Contributor Author

@amed Did you do the adb reverse command?

@amed
Copy link

amed commented Aug 16, 2018

Yes, the issue is with installing storybook.

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

No branches or pull requests

5 participants