import { useCombobox } from 'downshift' import { useState } from 'react' import { FzfHighlight, useFzf } from 'react-fzf' import { posts } from '../utils/data' import { Example } from '../utils/Example' function postToString(post: typeof posts[number] | null): string { return post?.title ?? '' } export function WithObjects() { const [query, setQuery] = useState('') const { getFzfHighlightProps, results } = useFzf({ items: posts, itemToString: postToString, query, }) const { getInputProps, getItemProps, getLabelProps, getMenuProps, getToggleButtonProps, highlightedIndex, isOpen, selectedItem, } = useCombobox({ items: results, itemToString: postToString, onInputValueChange: ({ inputValue }) => { setQuery(inputValue ?? '') }, }) return ( ) }