Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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]);
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