小编Ken*_*rma的帖子

无法在现有状态转换期间更新(例如在 `render` 内)。Render 方法应该是 props 和 state 的纯函数。在 Index.js 中

我正在为前端使用 react 和 react 钩子,但出现此错误:

index.js:1 Warning: Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state.
    in Login (created by Context.Consumer)
    in Route (at App.js:46)
    in AuthContextProvider (at App.js:37)
    in Switch (at App.js:36)
    in Router (created by BrowserRouter)
    in BrowserRouter (at App.js:32)
    in div (at App.js:30)
    in App (at src/index.js:9)
    in StrictMode (at src/index.js:8)
console.<computed> @ index.js:1
overrideMethod @ react_devtools_backend.js:2273
printWarning @ react-dom.development.js:88
error @ react-dom.development.js:60
warnAboutRenderPhaseUpdatesInDEV …
Run Code Online (Sandbox Code Playgroud)

javascript express reactjs react-context react-hooks

7
推荐指数
1
解决办法
2337
查看次数