I'm upgrading react-router-dom from v5 to v6 in a codebase I'm not entirely familiar with yet, and I am curious about how to replace the following code:
const history = useHistory();
history.replace(url, params);
In the docs they only display what you would do to replace in case there's 1 argument. so if I had:
history.replace(url)
I'd simply do:
const navigate = useNavigate();
navigate(url, {replace: true})
How do I ensure the second argument is kept with the useNavigate hook?
I'm tempted to do this:
const navigate = useNavigate();
navigate(url, params)
or
const navigate = useNavigate();
navigate(url, { state: params })
How should it be replaced without any impacts?