If you’re using react hooks, you can use window.history
directly to clear the state without triggering a rerender. This is better than using the useHistory
hook’s replace
method, which would cause your component to rerender.
window.history.replaceState({}, document.title)