Main use of this folder :- service/reducers
Index.js :- also known as rootReducer
// Reducer.js
import { ADD_TO_CART } from "../constants"
const initialState = {
cardData: []
}
export default function cardItems(state = [], action) {
switch (action.type) {
case ADD_TO_CART:
// console.warn("reducer",action)
return [
...state,
{cardData: action.data}
]
default:
return state
}
}
// Index.js
import {combineReducers} from "redux"
import cardItems from "./reducer"
export default combineReducers({
cardItems,
})
© www.thecoderjob.com. All Rights Reserved. Designed by HTML Codex