I am attempting to get the input out of a textbox using ReactJS but am not sure how
import React from 'react'
class component extends React.Component {
constructor() {
super()
this.state = {
word: String('')
}
}
increment() {
this.setState({
word: this.state.word += ''
})
}
render() {
return (
<div>
<p>The message is: { this.state.word } </p>
<input type="text" value={this.state.word} onChange={(event) =>this.handleChange(event.target.value)} />
<input type="submit" value="Add Word" onClick={() => this.increment()} />
{/*<p><input type="button" value="clear msg" onClick={() => this.eraseWord()} /></p>*/}
</div>
)
}
}
The text from the textbox should be added onto the message is:
render(){ ... }.