Shallow routing example throws TypeError: Cannot read property 'auth' of null
See original GitHub issueBug report
I’m not sure this is a bug, but it throws an error and it probably shouldn’t.
Describe the bug
Shallow routing following the docs throws TypeError:
Unhandled Rejection (TypeError): Cannot read property 'auth' of null
To Reproduce
Clone repo and run:
https://github.com/tgdn/nextjs-shallow-typeerror/
Expected behavior
Error should not be thrown.
System information
- OS: macOS
- Version of Next.js: tried both 9.3.2 and 9.3.3
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Next.js build version fails with 'Cannot read property 'auth' of ...
However as of yesterday we're suddenly getting an error on the production version when applying a router.push : Cannot read property 'url' ...
Read more >cannot read property 'usecontext' of null nextjs - You.com
Shallow routing following the docs throws TypeError: Unhandled Rejection (TypeError): Cannot read property 'auth' of null ...
Read more >Untitled
TypeError : Cannot read property 'getContext' of null I have created a game using ... Cannot destructure property `auth` of 'undefined' or 'null'...
Read more >Shallow Routing - Next.js
This is due to middleware being able to rewrite dynamically and can't be verified client-side without a data fetch which is skipped with...
Read more >Vue Router - Vue Testing Handbook
For example, if you are rendering your entire <App> component, chances are the render tree is large, containing many components with their own ......
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 came across the same problem in the docs and I found this issue, so I created a small PR to update the docs 😃
@tgdn @jamesmosier I came across the same issue while following the docs. I think the problem comes from here where
as
is initiated tourl
(typeof null
return alwaysobject
), and because passingnull
is different fromundefined
for the behaviour of default parameter value(see here) ,as
parameter doesn’t geturl
value when initiated tonull
.@timneutkens I can see 2 possibilities here:
undefined
instead ofnull
:router.push('/?counter=10', undefined, { shallow: true })
null
check foras
parameter inpush
function (maybe also in replace function), something like this in router.ts:I would be happy to submit a PR with either of these solutions 😊