Function updateFormValue

  • Convenience function to update a form value. Pass the Meiosis cell and the state property (such as 'firstName') or path (such as ['person', 'firstName']) into which to update the value. Returns a function that you can pass to a DOM handler, such as oninput (Mithril) or onInput (Preact, React). For example:

    // Using Mithil
    m('input[type=text]', { oninput: updateFormValue(cell, 'firstName') })

    // Using Preact/React
    <input type="text" onInput={updateFormValue(cell, ['person', 'firstName'])}/>

    Returns

    a function that accepts a DOM event and updates the value on the Meiosis state.

    Type Parameters

    • S

    Parameters

    • cell: MeiosisCell<S>

      the Meiosis cell.

    • path: string[] | Extract<keyof S, string>

      the property or path into which to update the value.

    • fn: ((value: string) => any) = ...

      (optional) a function to modify the value before updating it.

        • (value: string): any
        • Parameters

          • value: string

          Returns any

    Returns ((evt: any) => any)

      • (evt: any): any
      • Parameters

        • evt: any

        Returns any

Generated using TypeDoc