November 2018
Beginner
502 pages
10h 22m
English
In this section, we are going to render the validation error messages in the Field component:
<div className="form-group"> <label htmlFor={name}>{label}</label> {(type === "Text" || type === "Email") && ( ... )} {type === "TextArea" && ( ... )} {type === "Select" && ( ... )} {context.errors[name] && context.errors[name].length > 0 && context.errors[name].map(error => ( <span key={error} className="form-error"> {error} </span> ))}</div>
So, we first check that we have errors for the field name, and then use the map function in the errors array ...
Read now
Unlock full access