I have an array of string names and i want to do bellow
let accountcode:{a:1,b:2};
let array=["first","second",third];
this.setState({[array[0]:accountCode,array[1]:accountCode,array[3]:accountCode]})
but array is dynamic list and i should map in array and setState every item of it in one setState i try
object.setState(
{...stateName:accountCodes}
)
but not working and i also try below and not throw syntax error:
object.setState(
stateName.map(s=>{[s]=accountCodes})
)
what should i do?