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

163
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 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