【发布时间】:2016-05-13 19:55:41
【问题描述】:
将嵌套数据推入 List 内的 Map
谁能告诉我:
理想情况下,我如何通过特定的用户 ID 将任务推送给这些用户(列表项)?
提前致谢。
我的代码:
const initialState = Immutable.List([
Immutable.Map({
"id": 1,
"name": "Abe Bell",
"tasks": [
{
"id": 1,
"title": "Get haircut",
"status": false
}
]
}),
Immutable.Map({
"id": 2,
"name": "Chad Dim",
"tasks": [
{
"id": 2,
"title": "Get real job",
"status": false
}
]
})
])
【问题讨论】:
-
你的州有这样的结构吗?在我看来,您可以将其简化为只使用地图。尽管完全可以编辑当前结构,但它不必要地复杂。作为一般规则,出于性能/简单性的原因,尽可能选择地图而不是列表。