[React] Maximum update depth exceeded

Uncaught (in promise) Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops. 

這個錯誤是由於其他組件(或父組件)改變了當前組件的state導致的, 在render期間setState造成的超量賦值操作

解決辦法:

使用UNSAFE_componentWillReceiveProps賦值

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章