CopyPastor

Detecting plagiarism made easy.

Score: 0.8054068684577942; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2022-05-01
by ATTILA

Original Post

Original - Posted on 2020-05-06
by Harshal



            
Present in both answers; Present only in the new answer; Present only in the old answer;

check this answer [click here][1]

[1]: https://stackoverflow.com/questions/42217121/how-to-start-search-only-when-user-stops-typing
unction Search() { const [searchTerm, setSearchTerm] = useState('') useEffect(() => { const delayDebounceFn = setTimeout(() => { console.log(searchTerm) // Send Axios request here }, 3000) return () => clearTimeout(delayDebounceFn) }, [searchTerm]) return ( <input autoFocus type='text' autoComplete='off' className='live-search-field' placeholder='Search here...' onChange={(e) => setSearchTerm(e.target.value)} /> ) }

Implement using useEffect hook: function Search() { const [searchTerm, setSearchTerm] = useState('') useEffect(() => { const delayDebounceFn = setTimeout(() => { console.log(searchTerm) // Send Axios request here }, 3000) return () => clearTimeout(delayDebounceFn) }, [searchTerm]) return ( <input autoFocus type='text' autoComplete='off' className='live-search-field' placeholder='Search here...' onChange={(e) => setSearchTerm(e.target.value)} /> ) }

        
Present in both answers; Present only in the new answer; Present only in the old answer;