in react why we can access the "event" without passing it as an argument?

Viewed 126

version 1

**inside some component**
    
//define a function with "event" parameter
inputHandler=(event)=>{console.log(event.target.value)}
  
//invoke the function without the required argument  
render(){
  <input onChange={this.inputHandler} />
}

version 2

**inside some component**
    
//define a function with "event" parameter
inputHandler=(event)=>{console.log(event.target.value)}
    
//invoke the function with the required argument
render(){
  <input onChange={(e)=>this.inputHandler(e)} />
}

Both of the version would work in my point of view, but I don't understand that why the 1st version doesn't report an error for I don't pass any argument to it, since in the definition of the function, it requires "event" as an argument when being invoked

0 Answers
Related