Module: "useHandlers"

March 14, 2021 · View on GitHub

react-uniformed"useHandlers"

Module: "useHandlers"

Index

Type aliases

Functions

Type aliases

eventLikeHandlers

Ƭ eventLikeHandlers: Handler‹string | EventTarget | null, keyValueEvent‹string›, void›


keyValueEvent

Ƭ keyValueEvent: [string, T, EventTarget | null]


reactOrNativeEvent

Ƭ reactOrNativeEvent: SyntheticEvent | Event

Functions

useHandlers

useHandlers<T, K, R, Return>(...handlers: Handler‹T, K, R›[]): Handler‹T, K, Return›

Consolidates the specified list of functions into one function. This is useful for calling a list of functions with similar parameters. A great use case is creating a reset form function from a list of reset functions (see example below). In fact, the reset function from useForm is created using this function.

example

// create a reset form function by merging reset functions from other form hooks.
const reset = useHandlers(resetValues, resetErrors, resetTouches);

Type parameters:

T

K: T[]

R: Promise‹void› | void

Return

Parameters:

NameTypeDescription
...handlersHandler‹T, K, R›[]the list of specified functions.

Returns: Handler‹T, K, Return›

A single function. When this function is invoked, it will call each specified function in the order it was passed to this hook with the same arguments from the invocation. If one of the specified handlers returns a promise, then this function will also return a promise.