storybook-addon-next-router
storybook-addon-next-router copied to clipboard
`router is null` - How to lift router provider higher in the component tree?
When running Storybook, I'm getting the error Uncaught TypeError: router is null
presumably because I am using useRouter
in a provider that's rendering higher in the tree than RouterContext.Provider
My preview.js
looks like this
const AppDecorator = (storyFn) => <RootProviders>{storyFn()}</RootProviders>;
export const decorators = [mswDecorator, AppDecorator];
export const parameters = {
nextRouter: {
Provider: RouterContext.Provider,
},
//.....
Is there a way to render the Next router before any other providers? If not, this maybe should be considered a bug because as you'll see from the screenshots below, in a regular build the router is rendered above providers in the tree.
Regular app tree
Storybook tree