April 2018
Intermediate to advanced
284 pages
6h 43m
English
React provides ref non-DOM attributes to access the component. The ref attribute can be a callback function, and it will execute immediately after the component is mounted. So we will attach the ref attribute in our form element to fetch the values.
Let's take a quick look at our component after adding the ref attribute:
<div> <form ref = "form" onSubmit = {this.handleSubmitEvent}> <div className = "form-group"> <label htmlFor= "email"> Email <span style = {style} > * </span></label> <input type = "text" id = "email" className = "form-control" placeholder = "Enter your email address" required ref = "email" /> </div> <div className = "form-group"> <label htmlFor = "issueType"> Issue Type <span style = {style}> * </span></label> ...Read now
Unlock full access