import React, { memo, useRef, useEffect } from 'react'; import { FiSearch } from 'react-icons/fi'; import SearchResult from './SearchResult'; const Search = ({ search, onSearch }) => { const inputEl = useRef(); useEffect(() => { if (search.show) { inputEl.current.focus(); } }, [search.show]); const style = { display: search.show ? 'block' : 'none' }; let i = 0; const results = search.results.map(result => ( )); return (
onSearch(e.target.value)} />
{results}
); }; export default memo(Search);