Created
June 16, 2021 11:49
-
-
Save SysCall97/8b3387df90270e1e7f93727d2a8a9791 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const Parent = () => { | |
const [count, setCount] = useState<number>(0); | |
const printFunction = useCallback((text: string) => { | |
console.log(text); | |
}, []); | |
// some other functions | |
return ( | |
<div > | |
<div> | |
<span style={{marginRight: 10}}>{count}</span> | |
<button onClick={() => setCount((prev: number) => prev + 1)}>add parent count</button> | |
</div> | |
/* some jsx element*/ | |
<Child callback={printFunction} /> | |
/* some jsx element*/ | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment