File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ import React , { Fragment } from 'react'
2+ import { useSelector , useDispatch } from 'react-redux'
3+ import { actionTypes , selectors } from '../../features/counter'
4+
5+ const Counter : React . FC = ( ) => {
6+ const count = useSelector ( selectors . getCountValue )
7+ const dispatch = useDispatch ( )
8+
9+ return (
10+ < Fragment >
11+ < div className = "row" >
12+ < div className = "col s12 m6" >
13+ < div className = "card blue-grey darken-1" >
14+ < div className = "card-content white-text" >
15+ < span className = "card-title" > Counter component</ span >
16+ < h4 >
17+ Counter: < strong > { count } </ strong >
18+ </ h4 >
19+ < p >
20+ Here you can increment and decrement counter value using buttons
21+ below. All the state updates are performed via redux actions.
22+ </ p >
23+ </ div >
24+ < div className = "card-action" >
25+ < div className = "group" >
26+ < button
27+ className = "waves-effect waves-teal btn-flat blue"
28+ type = "button"
29+ onClick = { ( ) =>
30+ dispatch ( { type : actionTypes . DECREMENT_COUNTER } )
31+ }
32+ >
33+ decrement
34+ </ button >
35+ < button
36+ className = "waves-effect waves-teal btn-flat red"
37+ type = "button"
38+ onClick = { ( ) =>
39+ dispatch ( { type : actionTypes . INCREMENT_COUNTER } )
40+ }
41+ >
42+ increment
43+ </ button >
44+ </ div >
45+ </ div >
46+ </ div >
47+ </ div >
48+ </ div >
49+ </ Fragment >
50+ )
51+ }
52+
53+ export default Counter
Original file line number Diff line number Diff line change 1+ export { default } from './Counter'
You can’t perform that action at this time.
0 commit comments