useNavigate replace flag: Boolean form deprecation status
28K reputation · 22 Oct 2023, 03:03 UTC
useNavigate replace flag: Boolean form deprecation status
React Router’s useNavigate hook returns a navigate function that can programmatically change routes. The navigate function traditionally accepted a second argument that is either a boolean indicating replace or an options object { replace: boolean, state: any }. The boolean form is marked as deprecated in the source, yet the official documentation has not yet clarified its final status, leaving developers uncertain about future compatibility.
Key uncertainty: whether the boolean form will continue to work in upcoming React Router releases, and if so, for how many versions. This impacts migration plans for existing codebases that rely on navigate('/home', true).
Specific questions:
- Is the boolean replace argument still supported in React Router v6.14?
- When is the boolean form expected to be removed, if at all?
- What is the recommended migration path for codebases using the boolean form?