简体   繁体   English

在反应项目上出现“在呈现不同组件时无法更新组件(`BrowserRouter`)”错误

[英]getting "Cannot update a component (`BrowserRouter`) while rendering a different component" error on react project

enter code here在这里输入代码

here is the code snapshot of login which I getting the error in. I cannot solve it as a new react user please help.这是我收到错误的登录代码快照。作为新的 React 用户,我无法解决它,请帮忙。

The navigate function should be called as an intentional side-effect, not in directly in the component body as an unintentional side-effect. navigate function 应该作为有意的副作用调用,而不是直接在组件主体中作为无意的副作用调用。 Move that logic into an useEffect hook.将该逻辑移至useEffect挂钩中。

Example:例子:

useEffect(() => {
  if (user || userGoogle) {
    navigate(from, { replace: true });
  }
}, [navigate, user, userGoogle]);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 警告:在渲染不同的组件(`FormSocialIcon`)时无法更新组件(`BrowserRouter`) - Warning: Cannot update a component (`BrowserRouter`) while rendering a different component (`FormSocialIcon`) 在功能组件中收到错误消息“在呈现不同组件时无法更新组件(`Header`)”? - Getting error message "Cannot update a component (`Header`) while rendering a different component" in functional component? React-Native:无法在呈现不同组件时更新组件 - React-Native: cannot update a component while rendering a different component React-Bootstrap 模式未关闭。 错误:渲染不同组件时无法更新组件 (`OnboardPage`) - React-Bootstrap modal not closing. Error: Cannot update a component (`OnboardPage`) while rendering a different component 出现错误“渲染不同组件时无法更新组件”。 实现我正在尝试的正确方法是什么? - Getting error “Cannot update a component while rendering a different component”. What is the correct way to achieve what I'm attempting? React - 超过最大更新深度/在渲染不同组件时无法更新组件 - React - Maximum update depth exceeded / Cannot update a component while rendering a different component 警告:渲染不同组件时无法更新组件。 ReactJS - Warning: Cannot update a component while rendering a different component. ReactJS 渲染不同组件时无法更新组件(`App`) - Cannot update a component (`App`) while rendering a different component 警告:在渲染不同的组件(`History`)时无法更新组件(`App`) - Warning: Cannot update a component (`App`) while rendering a different component (`History`) 在呈现不同的组件 (`CellRenderer`) 时无法更新组件 (`Categoriess`) - Cannot update a component (`Categoriess`) while rendering a different component (`CellRenderer`)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM