-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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: "Can't find variable: document" #6910
Comments
Hey @alexakasanjeev, the issue happens because you include addons.js file inside storybook/index.js file. addons.js file is used only in web part of react native so there is no need to import it. |
@Gongreg So how do I use action addon, I am running storybook server, I am previewing stories on device and selecting stories from web browser, I want to see actions being logged, How do I do that? |
You should see the action list in the addon panel inside the web browser or you can use https://github.com/storybookjs/storybook/tree/next/addons/ondevice-actions if you want to see them in the app. Ping here if you can't get it to work. :) |
@Gongreg I am unable to see action in web browser, my addon panel is empty. I have the same code as above |
Maybe you need to pass in —config option to storybook start? I am not really sure what the issue might be :/ |
To see action panel in the addon panel, you need to add this line Can you tell me what kind of config I need to write in package.json?? |
Hey @alexakasanjeev, If you want to see actions addon inside web addons panel you have to do this:
That should be enough to get addons panel to appear in web. If you want to see actions addon inside react native addons panel you have to do this:
And that should be enough to get actions panel appear in react native. |
@Gongreg I have created a repo which has the setup and is giving can't find variable: document error. Please clone the https://github.com/alexakasanjeev/ecommerce-component-library/tree/bug/storybook-addon-error |
Hello. |
Hello @Gongreg, yes If i remove that line then the code is working fine, but the line is responsible for adding action tab, if I remove it then how will I see action tab in web browser. I want to see action being logged, how can I do that, can you please fork and create a pull request with right code? |
Hey @alexakasanjeev. I am on vacation right now and I don’t have access to a computer. I can look into it in few days. But the addons panel is supposed to work without including the line. When you run storybook server it automatically includes addons.js file for you. |
@Gongreg yes you are right the Thank you so much for all the support. :) I have a personal question, if you don't prefer to answer, I understand. |
I am facing the same issue. If I remove the following line from storybook/index.js my app works :
But as a result nothing shows up in the storybook web server. Is there any way for the web server and the app to work at the same time? |
@rakibhasan48 hello, I was having the same issue, the storybook wasn't loading in the browser, Make sure your storybook server and everything is running then if your are on ubuntu it will be now in terminal type cd home/your_username/Android/sdk/platform-tools then run ./adb reverse tcp:7007 tcp:7007 I did that and refresh the app in emulator/device and refresh the browser and stories were loading. |
This solved the problem. Thanks a lot. |
You welcome :) |
@alexakasanjeev Regarding your question. You are already contributing by asking questions and answering them. :) Helping out with docs and questions is as important as writing code. But since you want to contribute to bigger project with code Storybook should be really good place to start. It is already a big project but there are people who try to make sure (@ndelangen) that everyone can contribute here. Some other bigger repos have strict rules about making PRs for them. If you need ideas what code you can write then ir can be solving an annoying bug that keeps happening, adding a small feature, etc. If you do something that benefits your work chances are that it will also help others. If we were to talk specifically about react-native part of storybook it can be a little daunting, since there are no tests. But almost all pull requests are merged, since we don’t have strict standards for the code. We just want that you make sure that things you add work and thst it doesnt break other things. Also by contributing to small projects you are already bringing positive impact. So there is no shame in working on smaller projects. Also that should make you feel stronger when you want to contribute on bigger projects. If you have any questions always feel free to ask them here or you can PM me. :) Sorry if there are any typos, writing on the phone |
Thank you once again, I really appreciate you taking your time and helping newcomers and guiding. A years back I used to see OSS as this massive mountain that only experts used to climb, but as I started poking around github and started my own OSS project I get a hang of it, and my perspective changed. My main reason to do this is to improve my skills, to learn from the best and implement back that knowledge in my own project and my job. I will keep all the points you mention in mind. I am happy that now I can contribute to OSS(no matter how small it is) and somehow help others. |
Describe the bug
Getting "Can't find variable: document" error when launching React-Native app with storybook.
This is only coming when i am including this line
import '@storybook/addon-actions/register';
If I comment out above line in addon.js, then everything is working fine.
To Reproduce
Steps to reproduce the behavior:
npm i --save-dev @storybook/react-native
npm i -D @storybook/addon-actions
import '@storybook/addon-actions/register';
Expected behavior
The app should have shown stories instead get a error screen
Screenshots
Code snippets
package.json
storybook/index.js
storybook/addon.js
System:
Additional context
If I comment out code in addons.js then I am not getting that error
issue similar to #4063
The text was updated successfully, but these errors were encountered: