comments : {
byId : {
"comment1" : {
id : "comment1",
author : "user2",
comment : ".....",
},
"comment2" : {
id : "comment2",
author : "user3",
comment : ".....",
},
"comment3" : {
id : "comment3",
author : "user3",
comment : ".....",
},
"comment4" : {
id : "comment4",
author : "user1",
comment : ".....",
},
"comment5" : {
id : "comment5",
author : "user3",
comment : ".....",
},
},
allIds : ["comment1", "comment2", "comment3", "commment4", "comment5"]
}
在上面的例子中,我有什么理由需要包含它api
包括它。我认为这样你可以更快地计数,你可以排序,但通常我不了解是否存在性能问题。为什么在规范化状态下需要所有`ids`数组?
在这情况下需求从何而来?这当然不是JavaScript或React的东西。我不能为Redux说话。 –
这不是Redux的要求。 – Nit
我在几个问题中看到它。显然,这是丹·阿布拉莫夫是怎么做的本教程:https://egghead.io/lessons/javascript-redux-normalizing-the-state-shape – jonahe