Morrys Repositories

Morrys Repositories

  • Docs
  • GitHub

›API Reference

Home

  • Build forms in React with Relay

Getting Started

  • relay-forms
  • react-relay-forms
  • relay-forms-nodeps

Simple Example

  • Simple Example

API Reference

  • useFormSubmit
  • useFormSetValue
  • useFormState
  • useFormValue

useFormValue

useFormValue

This hook allows you to find out the value of the field

input parameters

key: key of the field whose value you want to retrieve

return

export type FormValueStateReturn<ValueType> = {
    readonly id: string;
    readonly value: ValueType | null;
    readonly error: string | null;
};

id: unique id in the store

error: the field validation error

value: the value of the field

example


export const Errors: React.FC<any> = () => {
    const data = useFormValue('firstName');
    return (
        <>
            <div>{data.error}</div>;
            <div>{data.value}</div>;
            <div>{data.id}</div>;
        </>
    );
};

Last updated on 16/11/2021 by morrys
← useFormState
  • useFormValue
Morrys Repositories
Docs
about relay-forms
Community
User Showcase
More
GitHubStar
Follow @m0rrys
Facebook Open Source
Copyright © 2023 Lorenzo Di Giacomo