UNPKG

downshift

Version:

🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.

14 lines (13 loc) 973 B
import { type Action, type Props, type State } from '../../utils-ts'; /** * Computes the controlled state using a the previous state, props, * two reducers, one from downshift and an optional one from the user. * Also calls the onChange handlers for state values that have changed. * * @param {Function} reducer Reducer function from downshift. * @param {Object} props The hook props, also passed to createInitialState. * @param {Function} createInitialState Function that returns the initial state. * @param {Function} isStateEqual Function that checks if a previous state is equal to the next. * @returns {Array} An array with the state and an action dispatcher. */ export declare function useEnhancedReducer<S extends State, P extends Partial<S> & Props<S, T>, T, A extends Action<T>>(reducer: (state: S, props: P, action: A) => S, props: P, createInitialState: (props: P) => S, isStateEqual: (prevState: S, newState: S) => boolean): [S, (action: A) => void];