Last active
March 28, 2020 19:44
-
-
Save cjoecker/4d22c93ca3c1842f733a867697200c7a to your computer and use it in GitHub Desktop.
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 from 'react'; | |
import {useDispatch, useSelector} from "react-redux"; | |
import {CounterActionTypes} from "../services/Counter_Actions"; | |
function Counter() { | |
const dispatch = useDispatch(); | |
const {counterNumber} = useSelector(state => state.Counter); | |
return ( | |
<div className="App"> | |
<h1>{counterNumber}</h1> | |
<button | |
onClick={(e) => { | |
dispatch({type: CounterActionTypes.SumCounter}) | |
}}> | |
Sum + 1 | |
</button> | |
| |
<button | |
onClick={(e) => { | |
dispatch({type: CounterActionTypes.SubtractCounter}) | |
}}> | |
Sum - 1 | |
</button> | |
</div> | |
); | |
} | |
export default Counter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment