Storybook 8: Using next/font/google when rendering storybook preview causes TypeError Cannot read properties of undefined (reading 'className') #26462
Replies: 2 comments 4 replies
-
My wild guess is that you are on a Windows machine. I can't reproduce the error even after following the reproduction steps. Does the error also occur if Storybook runs in Babel mode? To try this out, please create a
Next week, I have a Windows machine available, and then I will give it another try to reproduce the issue. |
Beta Was this translation helpful? Give feedback.
4 replies
-
I have identified the root cause and I am working on a fix. Please continue the discussion in the following issue if necessary: #26699 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
The
next/font/google
imported font is causingTypeError Cannot read properties of undefined (reading 'className')
on Storybook. I have searched and tried everything I could find including:.variable
instead of.className
enhanced-resolve
to version 5.10 from 5.11next/fonts/google
directly inpreview.tsx
File structure:
Note: Additionally I tried the default
stories
folder and files that are made automatically by runningnpx storybook@latest init
To reproduce:
npx create-next-app@latest
npx storybook@latest init
./src/lib/font.ts
./src/lib/font.ts
:src/app/layout.tsx
should be edited to appear as:npm run dev
the next web app.storybook/preview.ts
file should be edited to appear as:preview.ts
topreview.tsx
to fix the errorsnpm run storybook
Additional information
main.ts:
Note: This was untouched as it was autogenerated.
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions