Last active
April 8, 2019 14:21
-
-
Save andregardi/3c96c06b089ec4766f79fef65fa51929 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
| import React from 'react'; | |
| import useCustom from './customHook'; | |
| const Counter = () => { | |
| const [globalState, setGlobalState] = useCustom(); | |
| const add1Global = () => { | |
| const newCounterValue = globalState.counter + 1; | |
| setGlobalState({ counter: newCounterValue }); | |
| }; | |
| return ( | |
| <div> | |
| <p> | |
| counter: | |
| {globalState.counter} | |
| </p> | |
| <button type="button" onClick={add1Global}> | |
| +1 to global | |
| </button> | |
| </div> | |
| ); | |
| }; | |
| export default Counter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment