i've seen some stuff about computed property names for class components, is there a similar solution for functional components?
i have an initial state of {}.
const [choice, setChoice] = useState({})
as a button clicks, i'd like to add a new k:v to it dynamically.
onClick={()=>{
setChoice( props.choice[Key]=[Val] );
}
this doesn't seem to work...
and i'm hoping to add to the choice variable, like so: {"key":"val","key1":"val1",etc..)
i've also tried this:
class Choice {
constructor(key, value){
this.key = key,
this.value = value
}
}
but not sure how to adjust the onClick for it.