Darmikon
1/29/2017 - 3:02 PM

How to update deep nested structures in redux without headache with https://github.com/kolodny/immutability-helper

How to update deep nested structures in redux without headache with https://github.com/kolodny/immutability-helper

 var src = {
     obj: {
         nestedArr: [
             {
                 string: 'str_before'
             }
         ]
     },
     arr: [
         {
             num: 2
         }
     ]
 }


  console.log(update(src,{
      arr: {
          0: {
              num: {
                  $set: src.arr[0].num + 666
              }
          }
      },
      obj: {
          nestedArr: {
              0: {
                  string: {
                      $set: src.obj.nestedArr[0].string + '_after'
                  }
              }
          }
      }
  }));