我正在使用"受控"组件(setState()在组件内使用)并在尝试保存表单数据时间歇性地获取此错误.所述UserForm onSave呼叫返回到saveUser在下面的部件代码方法.
我已经查看了Redux文档,并且无法完全了解我正在修改状态以导致标题中的错误,具体是: Uncaught Error: A state mutation was detected between dispatches, in the path 'users.2'. This may cause incorrect behavior.
据我所知,只有本地修改,并且reducer返回一个全局状态的副本,并添加了我的更改.我一定错过了什么,但是什么?
这是组件代码:
import React, {PropTypes} from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import * as userActions from '../../actions/userActions';
import UserForm from './UserForm';
export class ManageUserPage extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
user: Object.assign({}, this.props.user),
errors: {},
saving: false
};
this.updateUserState = this.updateUserState.bind(this);
this.saveUser = this.saveUser.bind(this); …Run Code Online (Sandbox Code Playgroud)