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

'Can't find variable: document' with addon-actions, React Native #4642

Closed
torkelrogstad opened this issue Oct 30, 2018 · 5 comments
Closed

Comments

@torkelrogstad
Copy link

Describe the bug
When adding the actions addon, my app crashes on startup. I'm using TypeScript, React Native 0.57 (with Babel 7 transpilation instead of tsc compilation) and Storybook 4.0. The issue appears very similar to #4063

storybook/rn-addons.ts:

import '@storybook/addon-actions/register';

storybook/index.ts:

import { configure, getStorybookUI } from '@storybook/react-native';
import { AppRegistry } from 'react-native';

import './rn-addons';

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

// Refer to https://github.com/storybooks/storybook/tree/master/app/react-native#start-command-parameters
// To find allowed options for getStorybookUI
const StorybookUIRoot = getStorybookUI({});

AppRegistry.registerComponent('APP_NAME', () => StorybookUIRoot);

export default StorybookUIRoot;

Relevant parts of package.json:

 {
    "dependencies": {
        "react": "16.6.x",
        "react-dom": "^16.2.0",
        "react-native": "0.57.3",
    },
    "devDependencies": {
        "@storybook/addon-actions": "^4.0.0",
        "@storybook/addon-links": "^4.0.0",
        "@storybook/react-native": "^4.0.0",
        "babel-core": "7.0.0-bridge.0",
        "babel-jest": "^23.4.2",
        "babel-preset-react-native": "^5",
        "metro-react-native-babel-preset": "^0.45.0",
        "typescript": "^3.0.1",
    }
}

Expected behavior
I expect the action logger panel to appear on my device.

System:

  • OS: Ubuntu 18.04
  • Device: Nexus 5X (Android)
  • Browser: Not relevant
  • Framework: React Native, TypeScript
  • Addons: @storybook/addon-actions
  • Version: 4.0.0
@Gongreg
Copy link
Member

Gongreg commented Oct 30, 2018

Hey @torkelrogstad Actions addon is currently not supported in React Native.
You can use it in browser by registering them in addons.js file.

Only addons named on-device-* are supported on react native.

https://github.com/storybooks/storybook/blob/master/ADDONS_SUPPORT.md
This is the compatibility table.

Also you are really welcome to convert the addon to work on react native if you want to :)

@Gongreg Gongreg closed this as completed Oct 30, 2018
@Gongreg
Copy link
Member

Gongreg commented Oct 30, 2018

If you have any questions feel free to ask :)

@torkelrogstad
Copy link
Author

I guess I misread the table. Just so I understand it correctly: Just the ones marked with "*" are compatible with on-device React Native?

@Gongreg
Copy link
Member

Gongreg commented Oct 30, 2018

With on-device - yes. Only the ones with * . And you use them as @storybook/addon-ondevice-*. I know that we have only 3 right now, but I was working alone on them, so I couldn't covert all of them for react native.

Also we hope in long run to support all addons by displaying them as webviews in react native.

You can read more about Storybook for RN 4.0 here if you want to: https://medium.com/storybookjs/whats-new-in-storybook-4-0-react-native-741c7f481bbb

@torkelrogstad
Copy link
Author

Thank you!

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

No branches or pull requests

2 participants