鍍金池/ 問答/HTML/ 控制臺(tái)警告的提示該怎么解決呢 reactjs

控制臺(tái)警告的提示該怎么解決呢 reactjs

Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the GroupManag component.

回答
編輯回答
柒槿年

樓上的方法不是很贊同,這問題出現(xiàn)的原因是你的組件卸載了,但是setState確執(zhí)行了。正確做法是在卸載組件的時(shí)候:this.setState(() => {})

2017年12月22日 05:55
編輯回答
法克魷

組件沒有渲染之前,直接通過 this.state = {}去賦值就好。

2017年2月4日 05:23