UNPKG

envoc-form

Version:

Envoc form components

19 lines (17 loc) 590 B
import React from 'react'; export interface ServerErrors { [path: string]: string; } export interface ServerErrorContextProps { errors: ServerErrors; getError: (path: string) => string | undefined; setError: (path: string, errorMessage: string | undefined) => void; } /** Context to store the API errors from the server for the form. */ export const ServerErrorContext = React.createContext<ServerErrorContextProps>({ errors: {}, getError: (path: string) => { return undefined; }, setError: (path: string, errorMessage: string | undefined) => {}, });