【发布时间】:2018-01-21 16:28:56
【问题描述】:
我应该使用哪种生命周期方法来设置表单中的现有值?我不能<input value={this.props.title} />,因为我想将输入作为受控组件。
我可以在异步方法之后做一个承诺,但这会是反模式吗?
componentDidMount() {
this.props.fetchItem(this.itemId)
.then(v=>{this.setState({title: v.title})})
}
【问题讨论】:
标签: javascript reactjs ecmascript-6