Skip to content

Latest commit

 

History

History
executable file
·
65 lines (43 loc) · 2.18 KB

custom-field-usage.md

File metadata and controls

executable file
·
65 lines (43 loc) · 2.18 KB

Home / CustomField

CustomField

This widget is a form field wrapper for an input component whose value is to be included in a enclosing Formik form.

Usage

import { CustomField } from "react-simple-widgets/dist/custom-fields";

<CustomField name errorBuilder>
  {({ value, touched, error, setValue, setTouched, setError }) => {
    // Return custom form input
  }}
</CustomField>;
  • name: string

    The key of the widget's value in the Formik provider

  • value?: any

    The value of the widget

  • touched: boolean

    Determines if the component has received focus previously. This can be used to provide a specific styling

  • error?: string

    The error of this component. This is usually provided by the validation schema of the form

  • setValue?: (value: any) => void

    Sets the value of the widget

  • setTouched?: (touched: boolean) => void

    Sets the touched state of the widget

  • setError?: (error: any) => void

    Sets the error of the widget within the form holder. A widget with an error will prevent the form from submitting

  • errorBuilder?: (originalError: any) => string

    An optional error builder function. It is passed the error (if any) from the Formik form and you can return a custom error message

CustomField is the base for the other form widgets provided in this library.