-
-
Save anupkgurung/3f5980ce38a254af771ab3c92d459141 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
export const ComponentA = () => { | |
const [counter, setCounter] = useState(0) | |
return ( | |
<> | |
<div><b>i am the at {counter} counter</b></div> | |
<ComponentB setCounter={setCounter}/> | |
<ComponentC setCounter={setCounter}/> | |
</> | |
) | |
} |
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
export const ComponentB = ({setCounter}) => { | |
return ( | |
<> | |
<button onClick={()=>setCounter(counter => counter+1)}>Add One</button> | |
</> | |
) | |
} |
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
export const ComponentC = ({setCounter}) => { | |
return ( | |
<> | |
<button onClick={()=>setCounter(counter => counter+2)}>Add Two</button> | |
</> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment