I actually figured out how to get the result I need, but I was hoping that someone could breakdown whats going on here and why the other more straightforward paths I tried didnt work.
essentially I was needing to set some nested state at various levels using some variables(namely id of the element)
so I tried this way
handleClick = (e) => {
var x = e.target.id
console.log(this.state.fields[x])
!this.state.fields[x].disabled ? this.setState({[this.state.fields[x].disabled]:true}) : this.setState({[this.state.fields[x].disabled]:false})
}
This for whatever reason creates a state object "false" at the top level. This is weird to me because the console logs this.state.field[x] correctly.
I also tried the same but with
setState({[this.state.fields.x.disabled]:true})
and
setState({[fields.x.disabled]:true})
both of which wouldnt compile. Not to mention I cant even figure out how to easily update nested state properties...Surely there is an easy way!
Im pretty new to react so any explaination as to what the problems are here would be greatly appreciated. Ill post my solution(workaround)