Skip to content

Instantly share code, notes, and snippets.

@SysCall97
Created June 16, 2021 11:49
Show Gist options
  • Save SysCall97/8b3387df90270e1e7f93727d2a8a9791 to your computer and use it in GitHub Desktop.
Save SysCall97/8b3387df90270e1e7f93727d2a8a9791 to your computer and use it in GitHub Desktop.
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