Cannot read property 'prefetch' and 'push' of null
See original GitHub issueBug report
Cannot read property ‘prefetch’ and ‘push’ of null
This bug starts coming when I updated the next version from 9.1.4 to 9.5.2 for both production and dev build.
Describe the bug
Cannot read property ‘prefetch’ of null Cannot read property ‘push’ of null
Uncaught TypeError: Cannot read property 'prefetch' of null
at prefetch (link.tsx?5e4b:98)
at eval (link.tsx?5e4b:279)
at eval (link.tsx?5e4b:60)
at Array.forEach (<anonymous>)
at IntersectionObserver.rootMargin (link.tsx?5e4b:51)
link.tsx?5e4b:144 Uncaught TypeError: Cannot read property 'push' of null
at linkClicked (link.tsx?5e4b:144)
at onClick (link.tsx?5e4b:314)
at HTMLUnknownElement.callCallback (react-dom.development.js?61bb:336)
at Object.invokeGuardedCallbackDev (react-dom.development.js?61bb:385)
at invokeGuardedCallback (react-dom.development.js?61bb:440)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js?61bb:454)
at executeDispatch (react-dom.development.js?61bb:584)
at executeDispatchesInOrder (react-dom.development.js?61bb:606)
at executeDispatchesAndRelease (react-dom.development.js?61bb:713)
at executeDispatchesAndReleaseTopLevel (react-dom.development.js?61bb:722)
at forEachAccumulated (react-dom.development.js?61bb:694)
at runEventsInBatch (react-dom.development.js?61bb:739)
at runExtractedPluginEventsInBatch (react-dom.development.js?61bb:880)
at handleTopLevel (react-dom.development.js?61bb:5803)
at batchedEventUpdates$1 (react-dom.development.js?61bb:24401)
at batchedEventUpdates (react-dom.development.js?61bb:1415)
at dispatchEventForPluginEventSystem (react-dom.development.js?61bb:5894)
at attemptToDispatchEvent (react-dom.development.js?61bb:6010)
at dispatchEvent (react-dom.development.js?61bb:5914)
at unstable_runWithPriority (scheduler.development.js?3069:697)
at runWithPriority$2 (react-dom.development.js?61bb:12149)
at discreteUpdates$1 (react-dom.development.js?61bb:24417)
at discreteUpdates (react-dom.development.js?61bb:1438)
at dispatchDiscreteEvent (react-dom.development.js?61bb:5881)
To Reproduce
it’s coming when Link Tag is used in the Popover element (https://react-bootstrap-v3.netlify.app/components/popovers/)
<OverlayTrigger
overlay={(
<Popover id="popover-saved-item">
<Link href="/shopping-cart">
<a><h5>Your Saved Items wishlist</h5></a>
</Link>
</Popover>
)}
>
Click Popover
</OverlayTrigger>
Click on
Expected behavior
the error should not be there.
Screenshots
System information
- Version of Next.js: [e.g. 9.5.2]
- Version of Node.js: [e.g. 10.16.0]
Additional context
When I add prefetch={false}
to link then the prefetch error doesn`t come while rendering
but push error is still there on click of the Link
Issue Analytics
- State:
- Created 3 years ago
- Reactions:15
- Comments:28 (11 by maintainers)
Top Results From Across the Web
nextjs: TypeError: Cannot read properties of null (reading 'push')
Please try one of these: <Button type="button" onClick={(e) => router.push('/profile/dashboard')}> Test </Button>.
Read more >Cannot read property 'prefetch' and 'push' of null #16864
VS Code's tsserver was deleted by another application such as a misbehaving virus detection tool. Please reinstall VS Code. Manage Extension.
Read more >Route prefetching in Next.js - web.dev
js . The prefetch property is set to true on /margherita and to false on /pineapple-pizza .
Read more >attempt to read property "usertype" on null - You.com | The AI ...
This bug starts coming when I updated the next version from 9.1.4 to 9.5.2 for both production and dev build. Describe the bug....
Read more >next/router | Next.js
Before moving forward, we recommend you to read Routing Introduction first. ... useRouter is a React Hook, meaning it cannot be used with...
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 was able to work around the issue by mocking
next/link
instead ofnext/router
:@hems updating
.storybook/preview.js
to the following worked for our use case