Storybook preview hooks can only be called inside decorators and story functions.
See original GitHub issueIn NextJS 11.0.1 the initial Storybook does not render and throws an error:
Storybook preview hooks can only be called inside decorators and story functions.
Error: Storybook preview hooks can only be called inside decorators and story functions.
at invalidHooksError (hooks.js:240)
at useStoryContext (hooks.js:442)
at Module.useGlobals (hooks.js:487)
at WithNextRouter (decorators.js:11)
at hooks.js:186
at decorators.js:26
at decorators.js:62
at renderWithHooks (react-dom.development.js:14985)
at mountIndeterminateComponent (react-dom.development.js:17811)
at beginWork (react-dom.development.js:19049)
I use preview.tsx and my app initially does not render with the above error. But client side navigation works and renders accordingly.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:9 (3 by maintainers)
Top Results From Across the Web
"Storybook preview hooks can only be called inside ... - GitHub
Got the Storybook preview hooks can only be called inside decorators and story functions. error. Our decorator looks something like: import ...
Read more >React js using useState Hook - Stack Overflow
Storybook preview hooks can only be called inside decorators and story functions. Please help. My Full component import React,{ useCallback } ...
Read more >Decorators - Storybook - JS.ORG
A decorator is a way to wrap a story in extra “rendering” functionality. Many addons define decorators to augment your stories with extra...
Read more >Don't export hooks with the same names as the core React ...
I often end up importing the wrong one, resulting in a Storybook preview hooks can only be called inside decorators and story functions...
Read more >How to build connected components in Storybook - Medium
A decorator is wrapper code that runs inside the preview iframe. They enable you to control the story layout, how it's rendered, and...
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
I’m fully updated with NextJS, Storybook, and storybook-addon-next-router and experiencing the same issue. My project’s pretty complex so I’ll try to make a simpler project that reproduces the issue.
@Myzel394 the issue of the reproduction @dfalling had was due to having
@react-theming/storybook-addon
which is using the wrong hooks that storybook provides for addon creators. You might also be using an addon which also does this.