[英]What does useNavigate replace option do?
Either pass a
To
value (same type as<Link to>
) with an optional second{ replace, state }
arg or使用可选的第二个
{ replace, state }
arg 传递To
值(与<Link to>
类型相同)或
without saying what it does.不用说它做了什么。 So does it replace the whole history stack or just the current route?
那么它是替换整个历史堆栈还是仅替换当前路由? I have no idea.
我不知道。
The replace
options property is a REPLACE navigation action. replace
选项属性是一个替换导航操作。 It's a redirect, replacing the current entry in the history stack versus PUSHing a new entry onto the top like a regular navigation.这是一个重定向,替换历史堆栈中的当前条目,而不是像常规导航一样将新条目推到顶部。
navigate(path); // PUSH, navigate
navigate(path, { replace: true }); // REPLACE, redirect
The
useNavigate
hook returns a function that lets you navigate programmatically, for example after a form is submitted.useNavigate
钩子返回一个允许您以编程方式导航的函数,例如在提交表单之后。 If usingreplace: true
, the navigation will replace the current entry in the history stack instead of adding a new one .如果使用
replace: true
,导航将替换历史堆栈中的当前条目,而不是添加新条目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.