Skip to content

Instantly share code, notes, and snippets.

@kristijan-pajtasev
Created November 25, 2020 10:51
Show Gist options
  • Select an option

  • Save kristijan-pajtasev/b481fe9557dfe813323404ba417d4f6f to your computer and use it in GitHub Desktop.

Select an option

Save kristijan-pajtasev/b481fe9557dfe813323404ba417d4f6f to your computer and use it in GitHub Desktop.
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