Hello,
Gérer l’état localement d’abord
I had succed with this exercise.
I just have a problem with css of the submit button. it’s very small.
I tried to use ‘btn btn-default’ of Bootstrap but doesn’t work.
Normally I think button element has own default css.
What can I do to improve this ?
class DisplayMessages extends React.Component {
constructor(props) {
super(props);
this.state = {
input: '',
messages: []
}
this.handleChange = this.handleChange.bind(this);
}
// Add handleChange() and submitMessage() methods here
handleChange = (event) => {
this.setState({
input: event.target.value
})
}
submitMessage = () => {
//const tabMess = this.state.input
this.setState({
messages: [...this.state.messages, this.state.input],
input: ''
})
}
render() {
console.log(this.state)
const items = this.state.messages.map(item => <li>{item}</li>)
return (
<div>
<h2>Type in a new Message:</h2>
{ /* Render an input, button, and ul below this line */ }
<input value={this.state.input} onChange={this.handleChange} />
<button onClick = {this.submitMessage} className="btn btn-default"/>
<ul>{items}</ul>
{ /* Change code above this line */ }
</div>
);
}
};