História Push para redirecionar para outra página no React-Router V6
import React from 'react';
const LocationContext = React.createContext();
export default function Router({ children }) {
return (
<LocationContext.Provider
value={{
// The current location
location: window.location,
navigator: {
// Change url and push entry in the history
push(to) {
window.history.pushState(null, null, to);
},
// Change url and replace the last entry in the history
replace(to) {
window.history.replaceState(null, null, to);
},
// Go back to the previous entry in the history
back() {
window.history.go(-1);
},
// Go forward to the next entry in the history
forward() {
window.history.go(1);
},
// If we want to go forward or
// backward from more than 1 step
go(step) {
window.history.go(step);
}
}
}}
>
{children}
</LocationContext.Provider>
);
}
Goutamraj Sahu