mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
25 lines
643 B
TypeScript
25 lines
643 B
TypeScript
import {createContext} from 'react';
|
|
|
|
/**
|
|
* Context type used on 'classic' or 'old' forms.
|
|
*
|
|
* This is a very different type than what is used on the 'settings'
|
|
* forms which have MobX under the hood.
|
|
*/
|
|
export type FormContextData = {
|
|
form?: {
|
|
data: object;
|
|
errors: object;
|
|
onFieldChange: (name: string, value: string | number) => void;
|
|
};
|
|
};
|
|
|
|
/**
|
|
* Default to undefined to preserve backwards compatibility.
|
|
* The FormField component uses a truthy test to see if it is connected
|
|
* to context or if the control is 'uncontrolled'.
|
|
*/
|
|
const FormContext = createContext<FormContextData>({});
|
|
|
|
export default FormContext;
|