Created
February 1, 2021 22:38
-
-
Save AllGistsEqual/28d8872057073a3fc0affc2a23609265 to your computer and use it in GitHub Desktop.
This file contains 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
// File: src/components/demo/Counter.tsx | |
import React from 'react' | |
import { decrement, increment } from '../../redux/demo/counter' | |
import { useTypedDispatch, useTypedSelector } from '../../redux' | |
const Counter = (): React.ReactElement => { | |
const value = useTypedSelector(state => state.counter) | |
const dispatch = useTypedDispatch() | |
return ( | |
<> | |
<input type="text" disabled value={value} /> | |
<button type="button" title="increment" onClick={() => dispatch(increment(1))}> | |
+1 | |
</button> | |
<button type="button" title="increment" onClick={() => dispatch(decrement(1))}> | |
-1 | |
</button> | |
</> | |
) | |
} | |
export default Counter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment