“tipos de ação redux” Respostas de código

Reagir tipos de ação 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

tipos de ação 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

Respostas semelhantes a “tipos de ação redux”

Perguntas semelhantes a “tipos de ação redux”

Mais respostas relacionadas para “tipos de ação redux” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código