Warning: Cannot update during an existing state transition (such as within `rend

513 阅读1分钟

当运行react文件的时候,如果代码写的不规范,就容易报以下错误

Warning: Cannot update during an existing state transition (such as within render). Render methods

image.png

原因:在render的时候使用setState()方法改变了state,它应该是一个纯的函数,不应该在这个方法当中去改变state