“Jenis Tindakan Redux” Kode Jawaban

Bereaksi jenis tindakan redux

export const CREATE_TUTORIAL = "CREATE_TUTORIAL";
export const RETRIEVE_TUTORIALS = "RETRIEVE_TUTORIALS";
export const UPDATE_TUTORIAL = "UPDATE_TUTORIAL";
export const DELETE_TUTORIAL = "DELETE_TUTORIAL";
export const DELETE_ALL_TUTORIALS = "DELETE_ALL_TUTORIALS";
Junior Grepper

Jenis Tindakan Redux

export const CAMPSITES_LOADING = 'CAMPSITES_LOADING';
export const ADD_CAMPSITES = 'ADD_CAMPSITES';
export const CAMPSITES_FAILED = 'CAMPSITES_FAILED';

export const ADD_COMMENTS = 'ADD_COMMENTS';
export const COMMENTS_FAILED = 'COMMENTS_FAILED';

export const PROMOTIONS_LOADING = 'PROMOTIONS_LOADING';
export const ADD_PROMOTIONS = 'ADD_PROMOTIONS';
export const PROMOTIONS_FAILED = 'PROMOTIONS_FAILED';

export const PARTNERS_LOADING = 'PARTNERS_LOADING';
export const ADD_PARTNERS = 'ADD_PARTNERS';
export const PARTNERS_FAILED = 'PARTNERS_FAILED';
Helpless Hummingbird

Acions Redux

//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
);
Restu Wahyu Saputra

Jawaban yang mirip dengan “Jenis Tindakan Redux”

Pertanyaan yang mirip dengan “Jenis Tindakan Redux”

Lebih banyak jawaban terkait untuk “Jenis Tindakan Redux” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya