Is this syntax even correct? results is my array of object, it's nested.
notifications: {
...state.notifications,
results: [
...state.notifications.results,
{ ...state.notifications.results }
]
}
This should be work.
notifications: {
...state.notifications,
results: [
...state.notifications.results
]
}
It seems to me that you're trying to run this.setState
, and update your array whilst doing so.
The full command would be something like this:
this.setState({
notifications: {
...this.state.notifications,
results: [
...this.state.results,
// whatever you're trying to add goes here
]
}
});
I'm just guessing based upon the tags on your question. Feel free to comment and explain your situation further so I can tailor my answer to better suit your question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.