【发布时间】:2019-12-27 01:02:40
【问题描述】:
我的状态对象如下所示:
activeUsers: {
country: {userID:{userProfileObject}}
}
我正在尝试像这样更新状态
this.setState(
{
activeUsers: {
...this.state.activeUsers,
country: {userID: userProfileObject},
},
}
)
但它似乎不起作用.....有人知道为什么吗?
【问题讨论】:
-
也许你可以更具体一点。你遇到什么样的问题?另外,从您的状态描述中,不清楚您为什么添加
...this.state.activeUsers -
看你的代码,我看到你用相同的键
country更新数据。您可以提供有关问题的上下文和更多信息。
标签: react-native react-state-management react-state