require-context.macro
require-context.macro copied to clipboard
ReferenceError: can't find variable require
Hi there!
I was following the storybook tutorial but using it with react native. Is it working for RN?
- I installed require-context.macro
- I installed babel-plugin-macros
- Configured storybook to load stories
Here is my config file for storybook
My package.json
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
Are your stories using CSF or old API?
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.
Why would run Storybook inside the native app 🤔
Do your storyshots work, or no?
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?
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!
@kylemh Thanks man, I'll try some help over there.
Have the same problem any have you found anything @vinipachecov ?
@zerubeus Not really. Storybook needs a platform so this require context will not work, it only works for web from what I've understood.
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.