0
const navigate = useNavigate()
      <div
          className="back-page"
          onClick={() =>
            navigate(back_page, {
              state: { is_returning: new Date() },
            })
          }
        >
          <Button />
        </div>

When the APP navigates to back_page, it will retrieve the value for is_returning. And then it should clear this state. How do I clear this state?

1 Answers1

0

Assuming you're using react-router-dom, it's using History API by default, so basically there's no way to delete history state. However, you could replace current route with the same route but an empty state. Translate that back into react-router-dom, that's

navigate(currentUrl, {
    replace: true
})
Austaras
  • 901
  • 8
  • 24