Попробуй это. Используйте history.goBack()
и history.goForward()
.
import { useHistory } from "react-router-dom";
function Button({
variant,
color,
component,
action,
...props
}) {
const history = useHistory();
function handleClick() {
if(action === 'GOBACK') {
history.goBack()
} else {
history.goForward()
}
}
return (
<button
onClick={handleClick}
>
{props.children}
</button>
);
}
<Button
variant="outlined"
color="secondary"
action="GOBACK"
>
Next
</Button>