mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 10:03:31 +00:00
24 lines
484 B
Markdown
24 lines
484 B
Markdown
# Navigation
|
|
|
|
### Listen to url change
|
|
|
|
Listen for changes to the current location:
|
|
|
|
```js
|
|
const onLocationChanged = (location) => {
|
|
console.log(location.pathname);
|
|
console.log(location.query);
|
|
console.log(location.hash);
|
|
};
|
|
|
|
module.exports = GitBook.createPlugin({
|
|
init: (dispatch, getState, { Navigation }) => {
|
|
dispatch(Navigation.listen(onLocationChanged));
|
|
}
|
|
});
|
|
```
|
|
|
|
The `onLocationChanged` will be triggered for initial state.
|
|
|
|
### Changing the url
|