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

Using Storybook in a project with Wix's react-native-navigation? #1151

Closed
gianko opened this issue May 29, 2017 · 8 comments
Closed

Using Storybook in a project with Wix's react-native-navigation? #1151

gianko opened this issue May 29, 2017 · 8 comments

Comments

@gianko
Copy link

gianko commented May 29, 2017

I can't get it working... has someone tried it?

@Gongreg
Copy link
Member

Gongreg commented May 29, 2017

It does work :)

Give me few minutes for an example.

Inside your entry file:


import {Navigation} from 'react-native-navigation';

const StorybookUI = getStorybookUI({port: 7007, host: 'localhost'});
Navigation.registerComponent('YOUR_COMPONENT_NAME', () => StorybookUI);

Navigation.startSingleScreenApp({
  screen: {
    screen: 'YOUR_COMPONENT_NAME',
    title: 'Title'
  },
});

@ghost
Copy link

ghost commented Jun 17, 2017

This doesn't seem to be working for me. When installing React-Native-Navigation to your project, it requires you to do the following in Xcode:
screen shot 2017-06-17 at 12 12 38 am

But my react app was a create-react-native-app so there's no xcode project to open. Did you follow those instructions above by going into Xcode?

@Gongreg
Copy link
Member

Gongreg commented Jun 19, 2017

Yes, I don't know if RNN supports CRNA. I'll quickly ask around.

@Gongreg
Copy link
Member

Gongreg commented Jun 19, 2017

@SuttJ so RNN doesn't support CRNA.

@Gongreg Gongreg closed this as completed Jun 19, 2017
@Charlynux
Copy link

Take me some times to understand why Storybook stops on splash screen...

Just in case, I create a repository with correct configuration.
https://github.com/Charlynux/nativestorybook

@malcolm-kee
Copy link

Thanks @Charlynux for the sample.

For reference for anyone stumble upon this, I'm able to setup with the following changes on storybook.js:

import React, { Component } from "react";
import { AppRegistry } from "react-native";
import { Navigation } from "react-native-navigation";
import { getStorybookUI, configure } from "@storybook/react-native";

// import stories
configure(() => {
  require("./stories");
}, module);

// This assumes that storybook is running on the same host as your RN packager,
// to set manually use, e.g. host: 'localhost' option
const StorybookUIRoot = getStorybookUI({ port: 7007, onDeviceUI: true });

// react-native hot module loader must take in a Class - https://github.com/facebook/react-native/issues/10991
// https://github.com/storybooks/storybook/issues/2081
// eslint-disable-next-line react/prefer-stateless-function
class StorybookUIHMRRoot extends Component {
  render() {
    return <StorybookUIRoot />;
  }
}

Navigation.registerComponent("storybook.UI", () => StorybookUIHMRRoot);
Navigation.startSingleScreenApp({
  screen: {
    screen: "storybook.UI",
    title: "Storybook"
  }
});

export default StorybookUIHMRRoot;

@nenti
Copy link

nenti commented Aug 7, 2018

With RNN@v2

const StorybookUI = getStorybookUI({ port: 7007, onDeviceUI: true })
Navigation.registerComponent('storybook.UI', () => StorybookUI)
Navigation.events().registerAppLaunchedListener(async () => {
  await Navigation.setRoot({
    root: {
      component: {
        name: 'storybook.UI',
      },
    },
  })
})

export default StorybookUI

@kdawgwilk
Copy link

This still seems to blow up when adding the StorybookUI as another tab in RNN app rather than a single screen app

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

7 participants