diff options
Diffstat (limited to 'docs/api/navigation.md')
-rw-r--r-- | docs/api/navigation.md | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/api/navigation.md b/docs/api/navigation.md new file mode 100644 index 0000000..b0a1d2d --- /dev/null +++ b/docs/api/navigation.md @@ -0,0 +1,23 @@ +# 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 |