aboutsummaryrefslogblamecommitdiff
path: root/src/features/counter/Counter.jsx
blob: b8453b285271932b9bbf36665879f7bf19122ce8 (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>
      <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>
  )
}