Want to clear location state after navigating to some path in ReactJS? I think that you can use browserHistory replace method to replace history state with new one without someValue defined:
1 2 3 4 5 6 7 8 9 10 | export class myComponent extends component { componentWillMount() { const value = this.props.location.state.someValue; // clear state.someValue from history browserHistory.replace({ pathname: '/mycomponent', state: {} }); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.