So I am attempting to build a comment form with a textarea input. The user submits their name, email, and leaves a comment which gets saved and sent to another component in an object format. However I am lost on how to build this actual object and target each individual aspect of the form. Here is my attempt:
mySubmitHandler = event => {
event.preventDefault();
const message = {}
this.props.addMessage(message)
}
render() {
return (
<footer >
<form onSubmit={this.mySubmitHandler}>
<h1>Your name</h1>
<input type="text" name="name" onChange={this.nameHandler} />
<h1>Your email</h1>
<input type="text" name="email" onChange={this.emailHandler} />
<h1>Your message</h1>
<textarea onChange={this.contentHandler} />
<br />
<input type="submit" />
</form>
</footer>
)
};
};