Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

71
Vistas
Redux not returning object

I am finding myself in a rabbit hole lol. I am making a call to gett a list of objects and the call is successful, and I can see the data getting returned back. But I am not understanding why columnDefs is not getting updated with the success data.

defaultState = {
  columnDefs: []
}

export default function MarketReducer(state = defaultState,action ){
  switch (action.type){
        case GET_MARKETING_LIST:
            return Object.assign({}, state, {
                columnDefs: [],
            });
        case GET_MARKETING_SUCCESS:
           return Object.assign({}, state, {
                columnDefs: action.payload.data.column_headers.columnDefs,
            });
        case GET_MARKETING_FAIL:
            return Object.assign({}, state,{
                error: action.error,
                columnDefs: [],
            });
        default:
        return state;
  }
}

export function getMarketingProspects() {
        return {
            type: GET_MARKETING_LIST,
            payload: {
                request: {
                    url: "/marketing/customers",
                    method: "GET"
                }
            }
        };
}

Then I have a button that is triggering getMarketingProspects(). Problem is that store is not getting updated.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The reason as to why it was not setting it to the store is because the actions were named different, i had to add "LIST" to success and failed, this then worked.

GET_MARKETING_LIST: GET_MARKETING_LIST_SUCCESS: GET_MARKETING_LIST_FAIL:

about 4 years ago · Juan Pablo Isaza Denunciar

0

export function getMarketingProspects() {
  return (dispatch) => {
    dispatch({
      type: GET_MARKETING_LIST,
      payload: {
        request: {
          url: "/marketing/customers",
          method: "GET"
        }
      }
    })
  }
}

now, on the action button you should dispatch the getMarketingProspects function. Like this.

onClick={()=> useDispatch(getMarketingProspects())}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda