UNPKG

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.

19 lines (18 loc) 1.34 kB
import React from 'react'; declare type FieldValidComponentType = React.ComponentType<{ message: string; }>; /** * Takes a component that you provide and returns that component, passing in the message (which you provide here) as a prop called "message". * The message will display if there are no errors in that field, based on the validationObject you provide. * Whether the message is displayed only if that field has been touched is dependent on the fourth argument to this function, which defaults to true. * (Set it to false if you want to display the message even if the field hasn't been touched). * The component you provide must accept a single prop named "message", which you can use to display the 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 "message", which you use to display the message inside your component. * @param {string} message - The message you wish to display if there are no errors. * @returns {JSX.Element} JSX.Element */ export declare function fieldValid(name: string, component: FieldValidComponentType, message: string): JSX.Element; export {};