[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. 

起因: 

[React] Cant perform a React state update on an unmounted component 是props传值数据修改了引出的bug_第1张图片 

 [React] Cant perform a React state update on an unmounted component 是props传值数据修改了引出的bug_第2张图片

 

解决办法:

splice改slice, splice会改变源数据

 

原因:

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

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

你可能感兴趣的:(React,web前端)