{
"_id" : ObjectId("577c4b18b1216fd9cb1a2ffc"),
"username" : "John",
"todolist" : [
{
"_id" : ObjectId("577c4b36b1216fd9cb1a2ffd"),
"newtodo" : {
"tittle" : "Playing football"
}
}
],
"dateAdded" : ISODate("2016-07-06T00:04:40.914Z"),
"__v" : 0
}
我这样写道具数据库,但标题出错
<p className={styles['author-name']}><FormattedMessage id="by" /> {props.user.username}</p>
<p className={styles['author-name']}>{props.user.todolist['newtodo.tittle']}</p>
我需要知道如何喜欢 Proptypes.shape
user: PropTypes.shape({
username: PropTypes.string.isRequired,
todolist:PropTypes.arrayOf(PropTypes.shape({
newtodo: PropTypes.objectOf(PropTypes.string)({
tittle:PropTypes.string.isRequired,
})
})).isRequired,
请帮帮我 TT 我是 React 的新手