Sorry if this has been already answered.
But is there a way to execute a custom function on every navigation? Preferably without creating a custom
You can use onClick
to perform any action, say
console.log('Heading to /')} />
Replace console.log
with a function that would perform sessionStorage
update and such, and that's it.
Another way would be to use onEnter
prop of Route
component to execute a certain function per every route enter:
console.log('Entered /')} />
See the reference, or example with react-router and react-redux.