December 2019
Intermediate to advanced
598 pages
12h 21m
English
Now that we understand the React context, we are going to create a context for our generic form components. Let's carry out the following steps:
import { FC, useState, createContext } from 'react';
interface FormContextProps { values: Values; setValue?: (fieldName: string, value: any) => void;}
So, our context will contain the form values and a function to update them.
export const FormContext = createContext<FormContextProps>({ values: {},});
Notice that we are required to pass in an initial value ...
Read now
Unlock full access