diff options
author | Adrián Oliva <adrian.oliva@cimat.mx> | 2023-05-17 21:26:50 -0600 |
---|---|---|
committer | Adrián Oliva <adrian.oliva@cimat.mx> | 2023-05-17 21:26:50 -0600 |
commit | 593ab2d7d4ef972594131b125d9320c618e54691 (patch) | |
tree | 1d44587b3785f987e41d807370d8a04f27565170 /src/features/counter | |
parent | 163398f68444d278eb83543ba9798a6441c8af9f (diff) | |
download | ToDo-App-FE-593ab2d7d4ef972594131b125d9320c618e54691.tar.gz ToDo-App-FE-593ab2d7d4ef972594131b125d9320c618e54691.zip |
Redux used to add ToDos
WE MADE IT!! I don't know how, but it is functional. :'3
Diffstat (limited to 'src/features/counter')
-rw-r--r-- | src/features/counter/Counter.jsx | 30 | ||||
-rw-r--r-- | src/features/counter/counterSlice.js | 25 |
2 files changed, 0 insertions, 55 deletions
diff --git a/src/features/counter/Counter.jsx b/src/features/counter/Counter.jsx deleted file mode 100644 index b8453b2..0000000 --- a/src/features/counter/Counter.jsx +++ /dev/null @@ -1,30 +0,0 @@ -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> - ) -} diff --git a/src/features/counter/counterSlice.js b/src/features/counter/counterSlice.js deleted file mode 100644 index 4cb9993..0000000 --- a/src/features/counter/counterSlice.js +++ /dev/null @@ -1,25 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit' - -export const counterSlice = createSlice({ - name: 'counter', - initialState: { - value: 0, - }, - reducers: { - increment: (state) => { - // Redux Toolkit allows us to write "mutating" logic in reducers. It - // doesn't actually mutate the state because it uses the Immer library, - // which detects changes to a "draft state" and produces a brand new - // immutable state based off those changes - state.value += 1; - }, - decrement: (state) => { - state.value -= 1; - } - }, -}) - -// Action creators are generated for each case reducer function -export const { increment, decrement } = counterSlice.actions - -export default counterSlice.reducer |