Upgrade react-dom-router from 5.X to 6.X
Redirect => Navigate
Switch => Routes
history.replace() => navigate(to, {replace: true});
useHistory => useNavigate
history.push() => navigate()
navigate() usage
You need to wrap your params inside navigate into a state: {} object.
before:
history.push('/streaming/videnc/', { id: id, stats: true });
after:
navigate('/streaming/videnc/', {state:{ id: id, stats: true }});
useParams<EncoderStatisticsParameters>
One problem with navigate() is that you need the hook useNavigate(). If you are trying to use it from an exporter helper function, it doesn't look possible right away.
You can remove the separate Typescript module @types/react-router-dom
React-router-dom 6 has built-in Typescript support.
@types/react-router-dom must be removed from package.json
You can now use Outlet
Outlet
PrivateRoutes or customs AuthenticatedRoutes must be converted
https://dev.to/iamandrewluca/private-route-in-react-router-v6-lg5
Recent Comments