ga-wdi-exercises/project4

quick one on setting states and immutability helpers

Closed this issue · 2 comments

Just wanted to double check that this is a correct 'react friendly' approach to changing states.

import update from 'immutability-helper'
//
// Many lines down.....
//
  let synth = update(this.state.synth, {playing: {$set: true}})
      this.setState({
        synth: synth
      })

I believe this helper function creates a copy with a little less syntax than the Object.assign method. Just want to make sure before carrying on.

jsm13 commented

Oh rad, I haven't seen immutability-helper before. I think this is right if synth is an object with a top level property playing. Good find on this.

yeah, top level property is playing. thanks John - got everything up to speed at this point