[React] Cant perform a React state update on an unmounted component 是props传值数据修改了引出的bug

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method. 

起因: 

 

 

 

解决办法:

splice改slice, splice会改变源数据

 

原因:

react props是单向数据传输的, 但是项目用了splice修改了props的源数组数据, 导致控制台打印源数组数据展开是[]的现象; 

react 规定props是单向数据流, 但是没想到还能被修改到, 因此引出各种莫名其妙的bug, 谨以此发贴记录. 

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