1234567891011121314151617181920212223 |
- import { useDispatch, useSelector } from "react-redux";
- import {inc, dec, rnd} from '../actions';
- const Counter = () => {
- const counter = useSelector(state => state.counter);
- const dispatch = useDispatch();
- return (
- <>
- <div > {counter} </div>
- <button onClick={() => dispatch(dec())} > - </button>
- <button onClick={() => dispatch(inc())} > + </button>
- <button onClick={() => dispatch(rnd())} > rnd </button>
- </>
- )
- }
- export default Counter;
|