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