November 2018
Beginner
502 pages
10h 22m
English
The state for field values lives in the Form component. However, the values are rendered and changed with the Field component. The Field component doesn't have access to the state within Form, because the state lives in the Form instance and Field doesn't.
This is very similar to the compound Tabs component we implemented in the last chapter. We shared state between the components in the Tabs compound using React context.
We are going to use the same approach for our Forms component in this section:
interface IFormContext { values: IValues;}
The context just contains values that have the same type, IValues, as in our state.
Read now
Unlock full access