react-proforma
Version:
React Proforma helps you build simple to complex web forms with ease in React. -- Simplicity where you want it. Flexibility where you need it.
16 lines (15 loc) • 1.05 kB
TypeScript
import React from 'react';
declare type FieldErrorComponentType = React.ComponentType<{
error: string;
}>;
/**
* Takes a component that you provide and returns an array of your component, each of which has been provided the error message as a prop "error".
* The errors will be displayed only if that field has been touched, and there are errors to display (based on the validationObject you provided).
* This means the component you provide must accept a single prop named "error", which you can use to display the error message however you like inside the component.
*
* @param {string} name - A form element name that corresponds with a property on your "initialValues" object.
* @param {React.ComponentType<{ error: string }>} component - Any component that accepts a single string prop called "error", which you use to display the error message inside your component.
* @returns {JSX.Element} JSX.Element
*/
export declare function fieldError(name: string, component: FieldErrorComponentType): JSX.Element;
export {};