@react-md/form
Version:
This package is for creating all the different form input types.
19 lines (18 loc) • 1.06 kB
TypeScript
import type { Dispatch, SetStateAction } from "react";
declare type InputElement = HTMLInputElement | HTMLSelectElement;
declare type ChangeEventHandler<E extends InputElement> = React.ChangeEventHandler<E>;
declare type DefaultValue = string | number | readonly string[] | (() => string | number | readonly string[]);
declare type SetValue<T extends DefaultValue> = Dispatch<SetStateAction<T>>;
/**
* This hook can be used to control the state of a radio group or a select
* element.
*
* @param defaultValue - The default value. If you want the user to specifically
* choose a value, set this to the empty string.
* @param onChange - An optional change event handler to also call when the
* change event is triggered.
* @returns a list containing the current value, a change event handler, and
* then a manual value setter.
*/
export declare function useChoice<T extends DefaultValue = DefaultValue, E extends InputElement = InputElement>(defaultValue: T, onChange?: ChangeEventHandler<E>): readonly [T, ChangeEventHandler<E>, SetValue<T>];
export {};