-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
Main app does not load when importing and then conditionally rendering storybook in root index.js #147
Comments
did you try reloading the app using the dev menu or cmd + R / ctrl+R Also whats the purpose of this here ? @storybook/preset-create-react-app: ^1.5.2 => 1.5.2 Also can you please provide any errors that you have in the logs. |
I've actually been able to reproduce this and its possible to resolve this by changing the way you call the getStorybookUI function. instead of using
do this
Then whenever you use the storybook ui make sure that you call this function like
I'm still investigating the cause of this but this should help those that come across this. If you have any issues please let me know. |
@dannyhw Hello, I faced the issue too. Tried your workaround but it did not help. Storybook renders every time till I totally removed it from render. Want to admit I've restarted my app and metro server every time after any changes being provided. I used the storybook in a such way.
But it does not work even if use conditional render in the App, e.g.
My System Info
|
@goraug hey I'm not sure what exactly you tried but I'm pretty sure it would work if you changed it to be like:
The key thing is not calling getStorybookUI unless storybook is actually being rendered. |
Thank you, I try and let you know. My key point was to control storybook rendering via env variable cuz for some builds I would like to switch it on/off and don't edit code manually every time. |
@dannyhw Okay, I guess the problem is in the |
@goraug I usually will just create a json file and have a flag in there like
Then if you want you can make a simple node script to change the value there. Then you can use that in your package.json to automate swapping between storybook and the app. There is a somewhat relevant article here where they do something similar: But you don't really need to create multiple files for it, you can just write to the json file directly. |
@dannyhw Thank you, appreciate your help! |
Hello, I would like to add to this, despite the fact that the issue is closed. RN 0.63.4, existing application that we are wrapping SB around that is not an Expo application. We have tried the above approach, and while it works great when we want to render the SB UI, it fails when we want to change the dependent variable. However, we noticed that simply importing the Storybook file, without calling the function to return the UI component at all, causes our main app to not render correctly. I see a couple of cycle warnings pointing to addons
Trying to wrangle this around conditional importing with no success. Seems similar to Wondering if anyone else has experienced anything similar since this issue was closed. |
@elliotmrodriguez the require cycle is not related as far as I know. You can try using inline requires so as to not import storybook unless it's being used. Something like
|
Thanks for the feedback @dannyhw I'll give it a shot. |
I came across this issue again today and just adding here that a patch can be applied to solve the promises bug that also causes this issue see this comment here: #20 (comment) |
Describe the bug
We're trying to run storybook-native alongside our main react-native app and conditionally loading storybook or the main app based off of an env variable. Problem is is that anytime we set our STORYBOOK_NATIVE env variable to false the main app fails to register and the simulator is blank.
Expected behavior
Main app loads when env variable is false
Code snippets
System:
The text was updated successfully, but these errors were encountered: