import{useState}from'react';import{useUpdateEffect}from'./hooks';const[counter,setCounter]=useState(5);useUpdateEffect(()=>{console.log('Will be executed whenever the dependency updates, But won\'t be executed at first render');},[counter]);
import{useState}from'react';import{useTimeout}from'./hooks';const[counter,setCounter]=useState(5);const{clear,reset}=useTimeout(()=>setCounter(0),1000);// counter value is 5, and after 1000ms the value will be changed to 0 as we can see, and we also have 2 functions, clear that clears Timeout, and a Reset function.
import{useState}from'react';import{useDebounce}from'./hooks';const[term,setTerm]=useState('');useDebounce(async()=>awaitsearchAutoComplete(term),1000,[term]);// Typing in a search field, and we want to send a search auto complete request that returns array of auto complete words, but we want to send this request only after user stops typing for 1000ms