Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

76
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda