Using react, and redux, is it true that the render function should never call dispatch or setState()?
I get this error when using dispatch in the render function: “Cannot update during an existing state transition”.
Here they get the error when calling setState() from render().
Yes. The render()
function should not perform any side effects at all, you’d have to do this in a lifecycle method like componentDidUpdate()
.
1 Like
Calling dispatch from render sounds like an easy way to get a stack overflow error.
system
Closed
4
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.