constructor(props) {
super(props);
this.state = {
data: []
};
};
renderInput () {
return this.state.data.map(item => {
return <div>
<input type="text" value={item}/>
</div>
})
}
addInput () {
let data = this.state.data;
data.push('Новый инпут');
this.setState({ data: data });
}
render() {
return (<div>
<button onClick={this.addInput.bind(this)}>Добавить</button>
{this.renderInput()}
</div>
)
}