Documents / @faasjs/react / FormContextProvider
Function: FormContextProvider()
FormContextProvider<
NewT
>(props
):ReactNode
The provider component of the splitting context.
Type Parameters
• NewT extends FormContextProps
<Record
<string
, any
>, FormElementTypes
, FormRules
> = FormContextProps
<Record
<string
, any
>, FormElementTypes
, FormRules
>
Parameters
props
children
ReactNode
initializeStates
Partial
<NewT
>
An object containing initial values that will be automatically converted into state variables using useSplittingState hook. Each property will create both a state value and its setter following the pattern: value/setValue.
Example
<Provider
initializeStates={{
value: 0,
}}
>
// Children will have access to: value, setValue
</Provider>
#### memo
`true` \| `any`[]
Whether to use memoization for the children.
**Default**
false
`true`: memoize the children without dependencies.
`any[]`: memoize the children with specific dependencies.
#### value
`Partial`\<`NewT`\>
## Returns
`ReactNode`
## See
https://faasjs.com/doc/react/functions/createSplittingContext.html#provider
## Example
```tsx
function App() {
const [value, setValue] = useState(0)
return (
<Provider value={{ value, setValue }}>
<ReaderComponent />
<WriterComponent />
</Provider>
)
}