Created
November 25, 2020 10:52
-
-
Save kristijan-pajtasev/28fb6f536900ba0fee88d01b2af29044 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useEffect, useState} from "react"; | |
import Counter from "./Counter"; | |
function ConditionalEffects() { | |
const [firstCounter, setFirstCounter] = useState(0); | |
const [secondCounter, setSecondCounter] = useState(0); | |
useEffect(() => { | |
console.log("updated first counter") | |
}, [firstCounter]); | |
useEffect(() => { | |
console.log("updated first counter") | |
}, [secondCounter]); | |
return ( | |
<div> | |
<Counter onChange={setFirstCounter} /> | |
<Counter onChange={setSecondCounter} /> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment