Created
August 2, 2019 15:26
-
-
Save arnelenero/6461a81185cd073738fbbcc378d20024 to your computer and use it in GitHub Desktop.
React Entities example - CounterView component
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, { useCallback } from 'react'; | |
import { useCounter } from './entities'; | |
const CounterView = () => { | |
const [counter, { increment, decrement }] = useCounter(); | |
const handleClickIncrement = useCallback(() => increment(), []); | |
const handleClickDecrement = useCallback(() => decrement(), []); | |
return ( | |
<div>{counter.value}</div> | |
<button onClick={handleClickIncrement}>Increment</button> | |
<button onClick={handleClickDecrement}>Decrement</button> | |
) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment