我需要在reducers中验证类似字典的对象,但由于我已经在使用Babel,所以我不想求助于像Typescript这样的工具.
以此对象为例:
posts : {
byId : {
"post1" : {
id : "post1",
author : "user1",
body : "......",
comments : ["comment1", "comment2"]
},
"post2" : {
id : "post2",
author : "user2",
body : "......",
comments : ["comment3", "comment4", "comment5"]
}
}
allIds : ["post1", "post2"]
}
Run Code Online (Sandbox Code Playgroud)
我如何使用PropTypes 表达我对byId对象的期望?可能吗?如果是这样,怎么样?