skip to Main Content

Make useEffect fire only when SOME dependencies have changed – Reactjs

Consider the overly simplified situation: const [name, setName] = useState(""); const [check, setCheck] = useState(false); useEffect(() => { requestSomethingToAServer(check, name); }, [check, name]); return ( <div> <input type="text" value={name} onChange={(e) => setName(e.target.value)} /> <input type="checkbox" checked={check} onChange={(e) => setCheck(e.target.checked)} />…

VIEW QUESTION
Back To Top
Search