import { UseSelectGetItemPropsOptions } from "downshift"; import { Context, createContext, MutableRefObject } from "react"; import { SingleSelectedOption } from "../shared/types"; type SingleSelectContextType = { getItemProps: (options: UseSelectGetItemPropsOptions) => any; selectedItem: SingleSelectedOption; highlightedIndex: number; optionIndexRef: MutableRefObject; setOptionIndex: (newIndex: number) => void; }; const defaultContext: SingleSelectContextType = { getItemProps: () => {}, selectedItem: null, highlightedIndex: 0, optionIndexRef: { current: 0 }, setOptionIndex: () => {}, }; export const SingleSelectContext: Context = createContext( defaultContext, );