remove state from location on page load in react router dom code example Example: remove state from location on page load in react router dom history.replace('', null);