Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

ReferenceError: can't find variable require #31

Open
vinipachecov opened this issue Oct 29, 2019 · 9 comments
Open

ReferenceError: can't find variable require #31

vinipachecov opened this issue Oct 29, 2019 · 9 comments

Comments

@vinipachecov
Copy link

Hi there!

I was following the storybook tutorial but using it with react native. Is it working for RN?

  1. I installed require-context.macro
  2. I installed babel-plugin-macros
  3. Configured storybook to load stories

Here is my config file for storybook

image

image

My package.json

image

image

Steps to reproduce:

  • Create react native app with react-native init
  • Install and configure storybook
  • install require-context.macro
  • configure stories as in storybook tutorial
  • see error
@kylemh
Copy link
Member

kylemh commented Oct 29, 2019

Are your stories using CSF or old API?

@vinipachecov
Copy link
Author

vinipachecov commented Oct 29, 2019

I’m using the old API. this error was occuring only when running react-native run-ios. Because storybook needs a platform to run appropriately this means it is not working.
Storybook server itself is running fine.

@kylemh
Copy link
Member

kylemh commented Oct 29, 2019

Why would run Storybook inside the native app 🤔

Do your storyshots work, or no?

@vinipachecov
Copy link
Author

Well, on React Native it renders the components in the app.
So to run storybook you have to run inside the app.
At least this are the instructions in the official docs.
Storyshots isn’t only for testing?

@kylemh
Copy link
Member

kylemh commented Oct 29, 2019

Good to know about RN, Storyshots is definitely only for testing though.

You may want to head into the Storybook discord for more help! I'm not certain your issue relates to this macro or not, regardless I don't have the bandwidth to resolve your issue!

@vinipachecov
Copy link
Author

@kylemh Thanks man, I'll try some help over there.

@zerubeus
Copy link

Have the same problem any have you found anything @vinipachecov ?

@vinipachecov
Copy link
Author

@zerubeus Not really. Storybook needs a platform so this require context will not work, it only works for web from what I've understood.

@pke
Copy link

pke commented May 13, 2022

I am not quite understanding how this macro overrides the require function? I can't find such code, so since this is a babel compile time only macro, it should work inside the RN app too.

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

No branches or pull requests

4 participants