Last active
February 22, 2019 19:46
-
-
Save alirezamirian/c832c40dc1800a56d409cada73b50791 to your computer and use it in GitHub Desktop.
For medium post
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
interface UsageProps { | |
value?: number; | |
changeHandler?: (value: number) => number | void; | |
} | |
function Counter({value, changeHandler}: UsageProps) { | |
const [valueState, setValue] = useControllableState(value, changeHandler, 0); | |
return <div> | |
<span className="value">{valueState}</span> | |
<button className="btn" onClick={() => setValue(valueState + 1)}>Increase</button> | |
</div> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment