06. customHook πŸ‘©β€πŸŽ“πŸ‘¨β€πŸŽ“

In this activity, we will practice using custom Hooks by creating a useDebounce Hook that will delay the invoking of a function for a given number of milliseconds.

# Instructions

  • Replace your React application’sΒ srcΒ folder with starter/src.

  • Start the application in dev mode by running npm start in your terminal.

  • Open your browser toΒ localhost:3000Β and study the rendered application.

  • Update this application to accomplish the following:

  • Create a new custom Hook called useDebounce that takes in the two parameters value and delay.

  • Use setTimeout to handle the value of the debouncer.

  • Update the Search page so that the useEffect Hook is listening for the value returned from the useDebounce Hook. Pass in a delay value of 500.

  • The finished application should only search for a new article if there has been a period of 500 milliseconds without any user input.


βœ… Solutions

Solutions Click Here