Tell us what’s happening:
I have no idea why this code isn’t running
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.bind(this);
}
// add handleChange() and submitMessage() methods here
handleChange(e){
this.setState({
input = e.target.value
});
}
submitMessage(){
let newMessages = [...this.state.messages, this.state.input]
this.setState({
messages : newMessages,
input: ""
})
}
render() {
const message = this.state.messages.map(msg =>
<li>{msg}</li>
)
return (
<div>
<h2>Type in a new Message:</h2>
{ /* render an input, button, and ul here */ }
<input value={this.state.input} onChange = {this.handleChange} />
<button onClick={this.submitMessage}>Add message</button>
<ul>
{message}
</ul>
{ /* change code above this line */ }
</div>
);
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
.
Link to the challenge: