blob: b8453b285271932b9bbf36665879f7bf19122ce8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import React from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { decrement, increment } from './counterSlice'
export function Counter() {
const count = useSelector((state) => state.counter.value)
const dispatch = useDispatch()
return (
<div>
<h1>{count}</h1>
<div>
<button
aria-label="Increment value"
onClick={() => dispatch(increment())}
className='btn btn-outline-primary'
>
Increment
</button>
<button
aria-label="Decrement value"
onClick={() => dispatch(decrement())}
className='btn btn-outline-primary'
>
Decrement
</button>
</div>
</div>
)
}
|