-
Notifications
You must be signed in to change notification settings - Fork 61
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
router.events.emit('routeChangeError'); is not working #70
Comments
Is this related to this package? If so could you please share codesandbox something similar? |
This isn't related to this package but ik the solution. You are emitting you'll find
So you need to provide btw I'm saying to @apal21 that our |
@apal21 @imranbarbhuiya As @imranbarbhuiya points out, I think the cause of the error is the lack of arguments in the handler for routerChangeError. The documentation has a shallow as the third error event, but the library handler is trying to get the shallow from the second argument. |
Using You should do like this router.events.emit('routeChangeError',err, yoururl, {shallow}) |
@imranbarbhuiya I understand that the argument is for listen, not emit. When passing the argument with emit, what kind of content should be specifically passed? Upon investigation, I could not find an example of passing an argument with emit. I fork and fix the event handler and try. @apal21 |
this can help maybe const pageChangeHandler = (
url: string,
{ shallow }: { shallow: boolean }
) => {
if (!shallow) {
const answer = window.confirm(message);
if (!answer) {
router.events.emit('routeChangeError','routeChange aborted.', url, {shallow});
throw 'routeChange aborted.';
}
}
}; |
@imranbarbhuiya |
The text was updated successfully, but these errors were encountered: