1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Update README.md

This commit is contained in:
Guillermo Rauch 2016-12-30 17:37:06 -08:00 committed by GitHub
parent c890dc3573
commit 5ab71d16b1

View file

@ -282,21 +282,13 @@ If you are no longer want to listen to that event, you can simply unset the even
Router.onRouteChangeStart = null
```
##### Cancelled (Abort) Routes
Sometimes, you might want to change a route before the current route gets completed. Current route may be downloading the page or running `getInitialProps`.
In that case, we abort the current route and process with the new route.
If you need, you could capture those cancelled routes via `routeChangeError` router event. See:
If a route load is cancelled (for example by clicking two links rapidly in succession), `routeChangeError` will fire. The passed `err` will contained a `cancelled` property set to `true`.
```js
Router.onRouteChangeError = (err, url) => {
if (err.cancelled) {
console.log(`Route to ${url} is cancelled!`)
return
console.log(`Route to ${url} was cancelled!`)
}
// Some other error
}
```