Skip to content

Instantly share code, notes, and snippets.

@andregardi
Last active April 8, 2019 14:21
Show Gist options
  • Select an option

  • Save andregardi/3c96c06b089ec4766f79fef65fa51929 to your computer and use it in GitHub Desktop.

Select an option

Save andregardi/3c96c06b089ec4766f79fef65fa51929 to your computer and use it in GitHub Desktop.
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