这是合法的吗?
componentWillReceiveProps: function(nextProps) { if (typeof nextProps.contact != 'undefined') { this.setState({forename: nextProps.contact.forename}); this.setState({surname: nextProps.contact.surname}); this.setState({phone: nextProps.contact.phone}); this.setState({email: nextProps.contact.email}); } }
因为我不知道如何填写我的输入,仍然可以让用户编辑输入.所以我想出了这个解决方案,而不是试图操纵this.props.
有什么建议么?