问题描述
这是一种常见做法吗?通常推荐使用,也适用于 useState
?
通常是否建议将其转...
{
"id": "123","author": {
"id": "1","name": "Paul"
},"title": "My awesome blog post","comments": [
{
"id": "324","commenter": {
"id": "2","name": "Nicole"
}
}
]
}
...变成这样:
{
result: "123",entities: {
"articles": {
"123": {
id: "123",author: "1",title: "My awesome blog post",comments: [ "324" ]
}
},"users": {
"1": { "id": "1","name": "Paul" },"2": { "id": "2","name": "Nicole" }
},"comments": {
"324": { id: "324","commenter": "2" }
}
}
}
(示例取自 here)
我知道这与 redux 相关,但我正在努力确定它是否适用于 useState
、useReducer
或 React 上下文 api 等较新的东西。
在我的用例中,似乎我可以从这样做中受益,但不会受益太多,因为我想显示数据的方式与它从后端返回的方式一致。
>解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)