Search code examples
react-nativestorybook

react native storybook problem with process.env.STORYBOOK_ENABLED


I'm trying to set up the react-native-storybook (i'm using this tutorial https://storybook.js.org/tutorials/intro-to-storybook/react-native/en/get-started/). However, i am blocked to the point when i've to launch "yarn storybook" because for some motive the envinronment variable is not recognized.My package.json is:

"scripts":{
        ...,
        "storybook": "sb-rn-get-stories&& STORYBOOK_ENABLED='true' expo start"
    }

and my app.config.js is :

export default ({ config }) => ({
  ...config,
  name: "Storybook Tutorial Template",
  slug: "storybook-tutorial-template",
  extra: {
    storybookEnabled: process.env.STORYBOOK_ENABLED,
  },
});

i've tried to digit this command from "git bash", "powershell" and "prompt-windows" but without to resolve the proble. Someone have faced in this problem and resolved it?


Solution

  • if you are using Windows you need to change scripts like this(only the "&&" place):

        "storybook": "sb-rn-get-stories STORYBOOK_ENABLED='true' && expo start",
        "storybook:ios": "sb-rn-get-stories STORYBOOK_ENABLED='true' && expo start --ios",
        "storybook:android": "sb-rn-get-stories STORYBOOK_ENABLED='true' && expo start --android"
    

    Also you need to install Android Studio(this for running the storybook by yarn storybook:android and on the ExpoGo).