Tell us what’s happening:
Code is not passing test #5 and #6
Your code so far
class DisplayMessages extends React.Component {
constructor(props) {
super(props);
this.state = {
input: '',
messages: []
};
this.handleChange=this.handleChange.bind(this)
this.submitMessage=this.submitMessage(this)
}
handleChange(event) {
this.setState({
input: event.target.value
})
}
submitMessage() {
let msgs = [...this.state.messages, this.state.input]
this.setState({
messages: msgs,
input:''})
}
render() {
return (
<div>
<h2>Type in a new Message:</h2>
<input onChange={this.handleChange}
value={this.state.input} />
<button type="submit" onClick={this.submitMessage}>
Add message</button>
<ul>
{this.state.messages.map(msg => <li>{msg}</li>)}
</ul>
</div>
);
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react-and-redux/manage-state-locally-first