Skip to main content

Posts

Showing posts with the label custom hook

custom hook - useGeo

custom hook - useInterval

custom hook - The Facade pattern

https://wanago.io/2019/12/09/javascript-design-patterns-facade-react-hooks/ function useUsersManagement ( ) {    const [ users , setUsers ] = useState ( [ ] ) ;      function addUser ( user ) {      setUsers ( [        . . . users ,        user      ] )    }      function deleteUser ( userId ) {      const userIndex = users . findIndex ( user = > user . id === userId ) ;      if ( userIndex > - 1 ) {        const newUsers = [ . . . users ] ;        newUsers . splice ( userIndex , 1 ) ;        setUsers (          newUsers        ) ;      }  ...