B
B
balex7772021-11-25 14:58:48
JavaScript
balex777, 2021-11-25 14:58:48

How to clear history state of previous page in React?

Example, the Posts page opens with a redirect along with state

history.push(
      {
        pathname: '/posts',
        state: params,
      },
    );


then then I go to the third page. How to clean up that state on the third page so that there is no state in the browser when going back?

i tried history.replace("/posts", null) redirects me to 404 page even after that i click back twice, state is still there

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question