error while using requireContext
See original GitHub issueOnce we start to use requireContext in .storybook/config.js, running the storybook is giving me an error, I was following the exact steps mentioned in tutorial.
if I start to use const req = require.context('../src', true, /.stories.js$/);
, the stuffs work fine
PFB my package.json
{
"name": "taskbox1",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"storybook": "start-storybook -p 9009 -s public",
"build-storybook": "build-storybook -s public"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@storybook/addon-actions": "^5.1.7",
"@storybook/addon-links": "^5.1.7",
"@storybook/addon-storyshots": "^5.1.7",
"@storybook/addons": "^5.1.7",
"@storybook/react": "^5.1.7",
"react-test-renderer": "^16.8.6",
"require-context.macro": "^1.0.4"
}
}
node version : v10.13.0 yarn version: v1.15.2
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Difference between getContext() and requireContext() when ...
getContext() returns a nullable Context . requireContext() returns a nonnull Context , or throws an exception when one isn't available.
Read more >Got error when using require.context · Issue #1635 - GitHub
I got an error var req = require.context(path.join(ROOT, "src/pages"), ... js$/); ^ TypeError: require.context is not a function and I am on ...
Read more >Fragment: getContext vs requireContext | by Ivan Shafran
TLDR: use requireContext only when you are sure fragment is attached to its host(onResume, onViewCreated, etc). Android team annotated some sdk ...
Read more >Fragment | Android Developers
Static library support version of the framework's android.app.Fragment . Used to write apps that run on platforms prior to Android 3.0. When running...
Read more >Dan Lew on Twitter: "`requireContext()` and `context!!` are the ...
I use requireContext() because the exception and message in ... I prefer using the requireXxx methods and if I get an error, at...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi can you please update this post because it is so annoying when you follow steps and end up with errors. After so much time I figure that problem is missing dependencies. You need to install @babel/core and babel-loader for this to work. You said in your text that we need to use babel macro, and if that should make as know that we need to install this dependencies it is very unclear. So please add this two install commands in your text for future readers.
current version 5.1.9 works fine. thanks