apal21 / nextjs-progressbar

A simple Next.js progressbar component using NProgress.

Home Page:https://www.npmjs.com/package/nextjs-progressbar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot destructure `shallow` of `undefined`

nandorojo opened this issue · comments

image

We're getting this after setting showOnShallow={false}. I'm guessing there is a missing null check in there.

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.