December 2019
Intermediate to advanced
598 pages
12h 21m
English
All of the components beneath the provider can access the context via a Consumer component. Let's use this within the Field component:
import { FC, useContext, ChangeEvent } from 'react';import { FormContext } from './Form';
export const Field: FC<Props> = ({ name, label, type = 'Text' }) => ( <FormContext.Consumer> {context => ( <div css={css` display: flex; flex-direction: column; margin-bottom: 15px; `} > ... </div> )} </FormContext.Consumer>););
Read now
Unlock full access