Answer the question
In order to leave comments, you need to log in
What is the difference between these redirects in React?
There are two applications, one is used for redirect
const history = useHistory();
history.push(url);
import { push } from 'connected-react-router';
...
dispatch(push(url));
Answer the question
In order to leave comments, you need to log in
In the first case, the editor knows nothing about the router, the router is used by itself. In the second case, the router is attached to redax and the logic is wrapped in a middleware from connected-react-router. There is no difference in components. The difference is that the second method allows you to work with the router through special action dispatchers where there is no react - for example, in redux-thunk or redux-saga.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question