I was able to implement an event handler in my simple React app and I wanted to understand event.target.value more deeply. I have a guess, but I wanted to ask others so I can confirm or modify any false understandings.
So... how are we able to even use event.target.value in React? Does event belong to the Event Web API that I found here? Or is it more of a React thing?
Here is my code for reference
import React from 'react';
import Display from './Display';
export default class Search extends React.Component{
constructor(props){
super(props);
this.state = { userInput: '' };
this.onSubmit = this.onSubmit.bind(this);
this.updateInput = this.updateInput.bind(this);
}
updateInput(e){
this.setState({userInput: e.target.value});
}
onSubmit(){
const title = this.state.userInput;
console.log(title)
}
render(){
return(
<div>
<label>
Movie Search App
<br></br>
<input type="text" value={this.state.userInput} onChange={this.updateInput}/>
</label>
<br></br>
<input type="submit" value="Search" onClick={this.onSubmit}/>
<Display />
</div>
)
}
}