Can someone please explain how arrow functions syntax works? Why does onInputChange have no const, let, or var before it? I am trying to understand, but everywhere I look I can only find syntax similar to this one:
let arrowFunct = (a) => {a+1};
This makes sense. It creates a variable that is assigned what the arrow function returns.
On the other hand, onInputChange from the example below does not have any declaration. Can somebody please explain?
class App extends React.Component {
constructor(){
super();
this.state = {
input: ''
}
}
onInputChange = (event) => {
console.log(event);
}
render() {
return (
<div className="App">
<Particles className='particles' params={particleOptions}/>
<Navigation />
<Logo />
<Rank />
<ImageLinkForm onInputChange={this.onInputChange} />
{/*
<FaceRecognition />*/}
</div>
);
}
}
I do have another question that is more about React. "event" gets passed down from React.Component, right? It is a prop passed down from the Component class, and it gets created when the super() function runs inside the constructor.