December 2019
Intermediate to advanced
598 pages
12h 21m
English
Let's render the validation errors in Field.tsx by going through the following steps:
<FormContext.Consumer> {({ values, errors }) => ( ... )}</FormContext.Consumer>
<div css={ ... } > ... {errors[name] && errors[name].length > 0 && errors[name].map(error => ( <div key={error} css={css` font-size: 12px; color: red; `} > {error} </div> ))}</div>
We use the map function to iterate through all of the errors and render each one in a div element.
This completes the rendering of any validation error messages.
Read now
Unlock full access