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

164
Visualizações
Redux data not rerendering when setting value within object (Immutable.js)

I have an immutable.js Map stored in Redux that is structured like:

reduxObject: {
    details: {}
    ...
    objectToChange: {
       myPosts: [{
        name: 'someName',
        link: 'someLink',
       }],
       drafts: []
    }
}

I am trying to append the array objectToChange.myPosts in a reducer function using

let temp = state.getIn([objectToChange, myPosts])
temp.push(action.payloadData)
return state.setIn([objectToChange, myPosts], temp)

The redux data is getting updated, however the displayed redux data isn't getting rerendered. I was expecting the state.setIn to create a new immutable object causing react native to trigger a rerender. Any suggestions or help would be greatly appreciated. Thanks ahead of time

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

So I found a workaround to using immutable that i'm not sure is acceptable but it works. I am now using lodash's cloneDeep function.

  let temp = _.cloneDeep(state)
  temp[action.payloadType][action.payloadLoc].push(action.payloadData)
  return (temp)
about 4 years ago · Juan Pablo Isaza Relatório

0

Ok so cloneDeep was a bad workaround but i found the proper solution to the problem. I needed to return the statement like this:

case 'postNewItemFbData':
  let tempUpdate = state[action.payloadType][action.payloadLoc]
  tempUpdate.push(action.payloadData)
  return {
    ...state,
    [`${action.payloadType}.${action.payloadLoc}`]: tempUpdate
  }
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