呈现其他组件(“ TodoDelete”)时无法更新组件(“ ConnectFunction”)

时间:2020-05-29 05:15:16

标签: reactjs

Source code of the file generating the warning message

我正在尝试使用ReactJs构建Todo应用程序,并且在删除待办事项时会收到以下警告

Warning: Cannot update a component (`ConnectFunction`) while rendering a different component (`TodoDelete`). To locate the bad setState() call inside `TodoDelete`, follow the stack trace as described in https://github.com/facebook/react/issues/18178#issuecomment-595846312
in TodoDelete (created by ConnectFunction)
in ConnectFunction (created by Context.Consumer)
in Route (at App.js:18)
in Switch (at App.js:14)
in Router (created by BrowserRouter)
in BrowserRouter (at App.js:12)
in App (at src/index.js:22)
in StrictMode (at src/index.js:21)
in Provider (at src/index.js:20)

我无法理解此警告的原因。我尝试用类替换该函数,但仍然收到相同的警告。有人可以帮我吗?

0 个答案:

没有答案