Created
April 23, 2021 07:20
-
-
Save joboccara/c54a08b215b93dafb59a59f8c0e22b87 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 CountContext = React.createContext(null); | |
const CountContextProvider = ({ children }) => { | |
const [count, setCount] = React.useState(0); | |
const onClickMemo = () => | |
window.alert(`clickMemo, count: ${count}`); | |
return ( | |
<CountContext.Provider value={{ count, setCount }}> | |
<GrandParent>{children}</GrandParent> | |
<MemoComponent onClick={onClickMemo} /> | |
</CountContext.Provider> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment