Answer (Choose 1 answer)
import React. { Component } from 'react';
class Form extends Component {
constructor(props) {
super(props):
this.state = {
name: ".email: "
};
}
handlelnputChange(event) {
// TODO: Update the corresponding state property based on user input
}
</
render() { return (
<form>
<label>
Name:
<inputtype="text"
value={this.state.name}
onChange={this.handlelnputChange}
/>
</label>
<label>
Email:
<input
type="email"value={this.state.email}
onChange={this.handlelnputChange}
</label></form>
):
}
export default Form:
In the code above, how can we update the value of the name or email state based on the user input in the respective input fields?
A. Assign a new value to name or email using the assignment operator (=) inside the handlelnputChange method.
B. Call the method this.setState({ name: event.target.value }) or this.setState({ email: event.target.value }) inside the handlelnputChange method.
Exit 48