V
V
Vladimir Golub2019-11-08 18:14:49
React
Vladimir Golub, 2019-11-08 18:14:49

Route change event in react-router?

How can I allow a route change only after a certain event?
For example, state updates, after it is updated, do a redirect.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Suntsev, 2019-11-08
@GreyCrew

I think that it is possible to implement the transition between pages through a special method that would make the replace () event from the connected-react-router library (or another, depending on what your routing works through) after the appropriate manipulations with the state.
But in general, the approach of changing the path after updating the state seems strange to me due to the fact that usually this state is no longer used after switching pages.
It is better in this case to store the state in the redux store.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question