I have the following data structure:
this.state = {
client: {
abilities: [],
},
abilitiesDisplay: [],
and I am trying to set state of the client abilities empty array to abilitiesDisplay array, which has been mutated in the code and now has two items.
My set state function is as follows:
EDIT: the client and abilitiesDisplay are declared earlier in the function:
const {
client,
abilitiesDisplay
} = this.state;
this.setState(() => ({
client: {
...this.state.client,
abilities: [
...client.abilities,
abilitiesDisplay
],
}
}))
The set state is not working in this case and client.abilities is still and empty array. Is the error obvious?
state.clientclientandabilitiesDisplaywithout showing their declarations nor initializations.client.abilitiesandabiaitiesDisplay?