When I click on the add button, it should add an input and I have to save it.
Something like this but with Input. But the problem is the input are all different so that's why I don't know how to do
My code :
class Main extends Component {
constructor(props) {
super(props);
this.handleChangeCategorie = this.handleChangeCategorie.bind(this);
this.state = {
// I think it should be an array but I don't know
valueCategorie: ""
};
}
addCategorie(){
//Something to add input
}
handleSubmit() {
//Make something with the categorie
}
handleChangeCategorie(e) {
// I don't know if I can use this function for all Input
this.setState({ valueCategorie: e.target.value });
}
render() {
return <div className="container">
<input type="text" value={this.state.valueCategorie} onChange={this.handleChangeCategorie} />
<Button onClick={this.addCategorie}>Add Input</Button>
<Button onClick={this.handleSubmit}>Send</Button>
</div>;
}
}
I don't think it's the same question here because he uses something to count. Maybe there is an other way to it ? Or is it the only way ?