1.
// 先判断值是否变化,不重复执行应该就不会死循环了
componentWillReceiveProps (nextProps) {
if (!isEqual(this.props.defaultValues, nextProps.defaultValues)) {
this.props.form.setFieldsValue(nextProps.defaultValues)
}
}
2.
父组件传一个unique key 给子组件<AddUserModal key={(this.state.user.id || '0') + Date.now()} />
子组件在componentDidMount的时候使用setFieldsValue方法
原理貌似是 react在检测到key有变化的时候,会重新render