import { useState , useCallback } from "react" ; export const useInput = ( initialState ) => { const [ value , setValue ] = useState ( initialState ) ; const getValueCallback = useCallback ( ( e ) => { const { name , value } = e . target ; if ( typeof initialState === "object" ) { setValue ( ( prevState ) => ( { ... prevState , [ name ] : value , } ) ) ; return ; } setValue ( value ) ; } , [ ] ) ; return { value , setValue , getValueCallback } ; } ;