useNavigationType

useNavigationType

返回用户到达当前位置时使用的导航类型。

¥Returns the type of navigation used when the user arrived at the current location.

import { useNavigationType } from "@remix-run/react";

function SomeComponent() {
  const navigationType = useNavigationType();
  // ...
}

返回值

¥Return Values

  • PUSH:用户通过历史记录堆栈上的 push 操作进入当前页面:点击链接或提交表单等。

    ¥PUSH: The user came to the current page via a push action on the history stack: clicking a link or submitting a form, etc.

  • REPLACE:用户通过历史记录堆栈上的 replace 操作进入当前页面:使用 <Link replace> 点击链接,使用 <Form replace> 提交表单或调用 navigate(to, { replace: true }) 等。

    ¥REPLACE: The user came to the current page via a replace action on the history stack: clicking a link with <Link replace>, submitting a form with <Form replace> or calling navigate(to, { replace: true }), etc.

  • POP:用户通过历史记录堆栈上的 pop 操作进入当前页面:点击后退或前进按钮,调用 navigate(-1)navigate(1) 等。

    ¥POP: The user came to the current page via a pop action on the history stack: clicking the back or forward button, calling navigate(-1) or navigate(1), etc.

其他资源

¥Additional Resources

Remix v2.17 中文网 - 粤ICP备13048890号