Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const SearchBox = () => {
const tags = useSelector(getAllTags)
const { query, selectedTags, onChange } = useContext(SearchContext)
const [inputValue, setInputValue] = useState(query)
const [debouncedOnChange, cancel] = useDebouncedCallback(onChange, 300)
const options = [{ id: '', counter: tags.length }, ...tags].map(item => ({
...item,
value: item.id,
label: item.name
}))
const selectedOptions = selectedTags.map(tagId =>
options.find(({ id }) => id === tagId)
)
useEffect(
() => {
setInputValue(query)
},
[query]