在设计具有相关实体的状态形状时,官方Redux文档建议通过ID而不是嵌套来引用:http://redux.js.org/docs/basics/Reducers.html#note-on-relationships.
在一对多关系中,Normalizr会将引用放在关系的"一"侧,例如:
"posts": {
"1": {
...
comments: ["1", "2", "3"]
...
Run Code Online (Sandbox Code Playgroud)
这比将参考文献放在"多"方面要好吗?例如
"comments": {
"7": {
...
postId: "1"
...
Run Code Online (Sandbox Code Playgroud)
创建Redux商店时,我在哪里放置引用是否重要?