2021年4月8日星期四

What is event.target.value in React exactly?

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>      )    }  }  
https://stackoverflow.com/questions/67014481/what-is-event-target-value-in-react-exactly April 09, 2021 at 10:58AM

没有评论:

发表评论