e typescript 1

e typescript

// For onChange

update = (e: React.ChangeEvent): void => {
    this.props.login[e.currentTarget.name] = e.currentTarget.value

Here is what the above code is Doing:
1. We’re creating a new function called update.
2. We’re passing in an event of type React.ChangeEvent.
3. We’re setting the state of the component to the value of the input.
4. We’re binding the function to the component.
5. We’re passing the function to the onChange prop of the input.

Now, when the user types into the input, the state of the component will be updated.

Similar Posts