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] Actions Addon error in withActions #15

Open
mmeissonnier opened this issue Jan 30, 2020 · 0 comments
Open

[React Native] Actions Addon error in withActions #15

mmeissonnier opened this issue Jan 30, 2020 · 0 comments
Labels
addon: actions bug Something isn't working

Comments

@mmeissonnier
Copy link

Describe the bug
I use storybook in my RN project. I want to load my storybook only when i'm in dev mode.
To do so in my react navigation stack i do this :

const SwitchNavigator = createSwitchNavigator({
  Landing: LandingScreen,
  SignIn: SignInScreen,
  App: DrawerNavigator,
  Storybook: () => {
    if (__DEV__) {
      const StorybookUI = React.lazy(() => import('../storybook'));
      return (
        <Suspense fallback={Fragment}>
          <StorybookUI />
        </Suspense>
      );
    }
    return <View />;
  },

This seems to cause problems with the action addon. I've got this error
image

However, if in node_modules/@storybook/addon-actions/dist/preview/withActions.js at line 60, i change this :

var root = _global.document && _global.document.getElementById('root');

to this

var root = _global.document && _global.document.getElementById && _global.document.getElementById('root');

It works fine.

Thanks in advance for your help.
*
To Reproduce
Steps to reproduce the behavior:

  1. Install storybook with action addon in a basic RN project with react navigation
  2. Load storybook root UI with react.lazy / suspense in a navigation stack
  3. navigate to the screen with storybook
  4. See error

Expected behavior
I should see my storybook

System:
System:
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 13.3.0 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.2 - /usr/local/bin/npm
Browsers:
Chrome: 79.0.3945.130
Safari: 13.0.5
npmPackages:
@storybook/addon-actions: ^5.2.8 => 5.3.2
@storybook/addon-knobs: ^5.2.8 => 5.3.2
@storybook/addon-links: ^5.2.8 => 5.3.2
@storybook/addon-ondevice-actions: ^5.2.8 => 5.3.2
@storybook/addon-ondevice-knobs: ^5.2.8 => 5.3.2
@storybook/addons: ^5.2.8 => 5.3.2
@storybook/react-native: ^5.3.3 => 5.3.3
@storybook/react-native-server: ^5.3.3 => 5.3.3

Additional context
Add any other context about the problem here.

@shilman shilman transferred this issue from storybookjs/storybook Feb 2, 2020
@Gongreg Gongreg closed this as completed Feb 5, 2020
@Gongreg Gongreg reopened this Feb 5, 2020
@Gongreg Gongreg added addon: actions bug Something isn't working labels Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: actions bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants