aboutsummaryrefslogblamecommitdiff
path: root/src/features/counter/Counter.jsx
blob: d589bf9801d0cbd3ae63f9a4d0556c3612f2ccad (plain) (tree)
1
2
3
4
5
6
7
8
9
10


                                                      

                           

                                                           


          
           
               


                                               
                   
                 
                            
               

                                               
         
                   


                 
   
 
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>
      <div>
        <button
          aria-label="Increment value"
          onClick={() => dispatch(increment())}
        >
          Increment
        </button>
        <span>{count}</span>
        <button
          aria-label="Decrement value"
          onClick={() => dispatch(decrement())}
        >
          Decrement
        </button>
      </div>
    </div>
  )
}