react 警告Warning: Cannot update during an existing state transition (such as within `render`). Render

报错的原因:由于引用的子组件通过props进行传递,传递的过程中实际上已经处于render阶段了 ,render还没结束时一些操作会触发state改变,在这个阶段如果你再改变这个state值的话就会报这个错。

尽量不要在render的时候通过点击改变state

猜你喜欢

转载自www.cnblogs.com/banyouxia/p/13188698.html