import { ChangeEvent , useCallback , useState } from "react" ; const useSearch = ( ) => { const [ search , setSearch ] = useState < string > ( "" ) ; const onChangeSearch = useCallback ( ( e ) : void => { const { value } = e . target ; setSearch ( value ) ; } , [ ] ) ; const filterItem = useCallback ( ( item , b ) => { if ( item !== false ) { return item . filter ( ( args ) => args [ b ] . includes ( search ) ) ; } } , [ search ] ) ; return { filterItem , search , onChangeSearch , } ; } ; export default useSearch ;