笔记记录

杂记

React 生命周期与setState的一些坑

1、生命周期同一个路由中,参数改变加载新页面内容,会触发prop改变,进入componentWillReceiveProps (nextProps)生命周期,如果在这个周期中执行新的数据获取,使用antd form 表单组件,this.props.form.setFieldsValue会继续触发prop改变,会进入死循环。2、setState,赋值的时候注意对象赋值会改变源对象的值通过 Object.assign() 赋值// 使用 Object.assign() 

Powered By Z-BlogPHP 1.5.2 Zero

Copyright Your WebSite.Some Rights Reserved.