import React, { useState, useRef, useMemo, useEffect } from 'react'; import PropTypes from 'prop-types'; import ItemList from './item-list'; import ListItemSearch from './list-item-search'; export default function SearchableItemList({ className, defaultToAll, fuseSearchKeys, itemSelectorError, itemsToSearch = [], listTitle, maxListItems, onClickItem, onOpenImportTokenModalClick, Placeholder, searchPlaceholderText, hideRightLabels, hideItemIf, listContainerClassName, shouldSearchForImports, }) { const itemListRef = useRef(); const initialResultsState = useMemo(() => { return defaultToAll ? itemsToSearch : []; }, [defaultToAll, itemsToSearch]); const [results, setResults] = useState(initialResultsState); useEffect(() => { setResults(initialResultsState); // eslint-disable-next-line react-hooks/exhaustive-deps }, [initialResultsState.length]); const [searchQuery, setSearchQuery] = useState(''); return (