How do I clear location.state in react-router on page reload?

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)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)