Skip to content

Instantly share code, notes, and snippets.

@AllGistsEqual
Created February 1, 2021 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllGistsEqual/28d8872057073a3fc0affc2a23609265 to your computer and use it in GitHub Desktop.
Save AllGistsEqual/28d8872057073a3fc0affc2a23609265 to your computer and use it in GitHub Desktop.
// 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