Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

global variable next does not exist in storybook #464

Closed
bestLessons opened this issue Jan 19, 2024 · 3 comments · Fixed by #465
Closed

global variable next does not exist in storybook #464

bestLessons opened this issue Jan 19, 2024 · 3 comments · Fixed by #465
Labels
bug Something isn't working released

Comments

@bestLessons
Copy link

Context

What's your version of nuqs?

"nuqs": "^1.15.3",

[email protected]

Are you using:

  • ✅ The app router
  • ✅ The pages router
  • ❌ The basePath option in your Next.js config
  • ❌ The experimental windowHistorySupport flag in your Next.js config

Description

While running storybook useQueryState has a line window.next.version !== '14.0.3' -> which assumes that there is a global next variable inside storybook. But it doesn't exist.

I think it'd be better to add something like window.next?.version just to make it work by default

Reproduction

Steps to reproduce the behavior:

  1. Setup any storybook with a component that uses import { useQueryState } from 'nuqs'; and it will fail to render
@bestLessons bestLessons added the bug Something isn't working label Jan 19, 2024
@Meemaw
Copy link

Meemaw commented Jan 19, 2024

Facing this as well -> true in test environments.

I recommend you update your types to make next optional on the window to avoid such errors in future:

@franky47
Copy link
Member

Thanks, I had fixed it in a previous place but this one slipped through. Types updated, marked as optional, and release baking in the oven.

Copy link

🎉 This issue has been resolved in version 1.15.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants