Skip to content

Latest commit

 

History

History
46 lines (32 loc) · 743 Bytes

useFormValue.md

File metadata and controls

46 lines (32 loc) · 743 Bytes
id title
use-form-value
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>;
        </>
    );
};