Cannot destructure `shallow` of `undefined`
nandorojo opened this issue · comments
https://github.com/apal21/nextjs-progressbar/blob/master/src/index.tsx#L87-L93
Here's the problem.
PR opened at #107
is your issue related to #70 (comment)?
Not sure, that comment isn’t that clear. I don’t think so. It’s just because the object containing shallow can be undefined but the handler in this library treats it as required.
My PR fixes it
according to nextjs docs, the object containing shallow will be always there so there's no need to pass a default, check https://nextjs.org/docs/pages/api-reference/functions/use-router#routerevents
The comment I link is for the same issue but it was caused by manually emitting this event. If u are manually emitting this event without the 2nd param then it'll throw. So check if the event u are receiving is coming from nextjs or emitted from your code. If it's from your code then add the shallow part in the event emit param
Thanks for the explanation, that's very useful to know. We are using events.emit('routeChangeError')
somewhere without the second argument, so it's likely due to that. My apologies for the incorrect issue.
is your issue related to #70 (comment)?
Also, small thing, when I originally clicked the comment you linked to on GH mobile, it sent me to a different one higher on the page. Now that I click it on desktop it takes me to yours, which does indeed explain the issue properly. So that's my mistake.