gpt4 book ai didi

So useNavigate is not recommended at all?(所以根本不推荐使用导航?)

转载 作者:bug小助手 更新时间:2023-10-28 22:14:44 26 4
gpt4 key购买 nike



I see in https://reactrouter.com/en/main/hooks/use-navigate at "It's usually better to use redirect in loaders and actions than this hook" So should I change useNavigate to redirect instead right ?

我在https://reactrouter.com/en/main/hooks/use-navigate中看到“在加载器和操作中使用重定向通常比在这个钩子中使用重定向更好”,所以我应该将useNaviate改为重定向吗?


更多回答
优秀答案推荐


So should I change useNavigate to redirect instead right?



No, not at all. Use the useNavigate hook, and returned navigate function to issue imperative navigation actions just as it's always been done/used in react-router-dom@6 since it was introduced.

没关系,您请。使用useNavigate挂钩和返回的导航函数来发出命令性导航操作,就像它自引入以来一直在Reaction-Router-Dom@6中所做/使用的那样。


[email protected] introduced many new features relying on the new router creators that add much more functionality to the behavior of the routing context, specifically the new data APIs. In this specific case it's informing you that you shouldn't try using the useNavigate hook in a loader. Loaders are functions called by the router to make some asynchronous data request for resources that are passed to the route's component. Only use redirect in the loaders, not navigate.

[受保护的电子邮件]引入了许多依赖于新的路由器创建者的新功能,这些创建者为路由上下文的行为添加了更多功能,特别是新的数据API。在本例中,它是在通知您不应该尝试在加载器中使用useNavigate挂钩。加载器是路由器调用的函数,用于对传递给路由组件的资源进行一些异步数据请求。只能在加载器中使用重定向,而不是导航。


更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com