Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react router remove location state on refresh

import createHistory from 'history/createBrowserHistory'

...

componentDidMount(){
    const history = createHistory();
    if (history.location.state && history.location.state.transaction) {
        let state = { ...history.location.state };
        delete state.transaction;
        history.replace({ ...history.location, state });
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #react #router #remove #location #state #refresh
ADD COMMENT
Topic
Name
7+8 =