redux actions.js
export const UPDATE_PRODUCTS = "UPDATE_PRODUCTS";
export const UPDATE_CATEGORIES = "UPDATE_CATEGORIES";
export const UPDATE_CURRENT_CATEGORY = "UPDATE_CURRENT_CATEGORY";
redux actions.js
export const UPDATE_PRODUCTS = "UPDATE_PRODUCTS";
export const UPDATE_CATEGORIES = "UPDATE_CATEGORIES";
export const UPDATE_CURRENT_CATEGORY = "UPDATE_CURRENT_CATEGORY";
redux acions
//npm i redux-actions or yarn add redux-actions
// single action creator
export const incAsyncCreator = createAction("INC");
export const decAsyncCreator = createAction("DEC");
// single action creator using - single reducer
export const incReducer = handleAction(
incAsyncCreator,
(state, action) => ({
...state,
counter: state.counter + 1,
success: action.payload.success
}),
counterState
);
// single action creator using - single reducer
export const decReducer = handleAction(
incAsyncCreator,
(state, action) => ({
...state,
counter: state.counter + 1,
success: action.payload.success
}),
counterState
);
//multiple action creator
export const { increment, decrement } = createActions({
increment: (payload) => ({ ...payload }),
decrement: (payload) => ({ ...payload })
});
// multiple action creator using - multiple reducer
export const counterReducer = handleActions(
{
[increment]: (state, action) => ({
...state,
counter: state.counter + 1,
success: action.payload.success
}),
[decrement]: (state, action) => ({
...state,
counter: state.counter - 1,
success: action.payload.success
})
},
counterState
);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us