Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!