UNPKG

downshift

Version:

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

17 lines (16 loc) 1.18 kB
import { Reducer } from '../../utils'; import { UseComboboxMergedProps, UseComboboxReducerAction, UseComboboxState } from '../index.types'; /** * The useCombobox version of useControlledReducer, which also * checks if the controlled prop selectedItem changed between * renders. If so, it will also update inputValue with its * string equivalent. It uses the common useEnhancedReducer to * compute the rest of the state. * * @param reducer Reducer function from downshift. * @param props The hook props, also passed to createInitialState. * @param createInitialState Function that returns the initial state. * @param isStateEqual Function that checks if a previous state is equal to the next. * @returns An array with the state and an action dispatcher. */ export declare function useControlledReducer<Item>(reducer: Reducer<UseComboboxState<Item>, UseComboboxReducerAction<Item>>, props: UseComboboxMergedProps<Item>, createInitialState: (props: UseComboboxMergedProps<Item>) => UseComboboxState<Item>, isStateEqual: (prev: UseComboboxState<Item>, next: UseComboboxState<Item>) => boolean): [UseComboboxState<Item>, (action: UseComboboxReducerAction<Item>) => void];