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

Cannot read property 'prefetch' of null error on StoryBook #19825

Closed
hems opened this issue Dec 4, 2020 · 11 comments
Closed

Cannot read property 'prefetch' of null error on StoryBook #19825

hems opened this issue Dec 4, 2020 · 11 comments
Labels
bug Issue was opened via the bug report template.

Comments

@hems
Copy link

hems commented Dec 4, 2020

Bug report

Describe the bug

Cannot read property 'prefetch' of null error is being displayed on StoryBook when making a storybook of an item with <Link> after updating to Next 10

To reproduce

Create a component with the following content:

      <Link href="/" prefetch={false}>
        <Box as="a" justifyItems="center" display="flex">
          ....
        </Box>
      </Link>

Expected behavior

Components should render normally as previously experienced on Next 9.

Currently to work around this issue i'm adding prefetch={false} to the Link objects but that disables the prefetch on the website which is not desirable

Screenshots

image

System information

  • OS: Linux
  • Browser (if applies): chrome
  • Version of Node.js: 14
@hems hems added the bug Issue was opened via the bug report template. label Dec 4, 2020
@PaulCaruana
Copy link

I am having the same issue. If you go back to next 9.5.5 it works then go back 10.0.x it fails. Having said that it appears to a timing issues when doing yarn install. It started working on one of my projects (with 10.0.3) and when I deleted yarn.lock and re-did yarn install it failed. I spent all afternoon trying to figure this out.

@timneutkens
Copy link
Member

Duplicate of #16864

@timneutkens timneutkens marked this as a duplicate of #16864 Dec 8, 2020
@ybrodsky
Copy link

ybrodsky commented Dec 8, 2020

#16864 refers to jest. The solutions / hacks provided there dont work on storybook.

@hems
Copy link
Author

hems commented Dec 8, 2020

Duplicate of #16864

indeed the other error is on jest / tests.. not on storybook

@timneutkens
Copy link
Member

It's the same issue though.

@ybrodsky
Copy link

ybrodsky commented Dec 9, 2020

The proposed solution doesnt work here. Closing this is the same as ignoring it.

@hems
Copy link
Author

hems commented Dec 10, 2020

The proposed solution doesnt work here. Closing this is the same as ignoring it.

@ybrodsky i have made a comment in the other issue, maybe @timneutkens or someone else will be able to help..

@damusnet
Copy link
Contributor

I believe #19857 would solve both but I need help to write the integration test.

@gfortaine
Copy link
Contributor

gfortaine commented Jan 5, 2021

storybookjs/storybook#12997

       <Link href="/" prefetch={!process.env.STORYBOOK}>
         <Box as="a" justifyItems="center" display="flex">
           ....
         </Box>
       </Link>

@hems
Copy link
Author

hems commented Jan 5, 2021

storybookjs/storybook#12997

       <Link href="/" prefetch={!process.env.STORYBOOK}>
         <Box as="a" justifyItems="center" display="flex">
           ....
         </Box>
       </Link>

Thanks for the suggestion @gfortaine but the solution presented in this comment is cleaner as it doesn't involved modifying the application code, instead, we just mock the router on the storybook.

I can see how checking if the application is running inside of storybook and setting prefetch to false would be great, but that would have to be added to the Router on Next.js and not on all links inside of an application!

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

7 participants