【发布时间】:2018-05-02 15:17:00
【问题描述】:
我的 redux 商店中有以下诗歌 json:
poems: {
'5a0f3367af648e17fa09df5d': { //this is my poem id
_id: '5a0f3367af648e17fa09df5d', //this is also the same as above
title: 'my first poem',
text: 'some lorem ipsum long text ',
userId: '5a03f045995c0f5ee02f9951', //this is my user id
__v: 0
},
'5a0ff2a5b4a9591ecb32d49c': {
_id: '5a0ff2a5b4a9591ecb32d49c',
title: 'my second poem',
text: 'some lorem ipsum long text',
userId: '5a03f045995c0f5ee02f9951', //this is the same user id as above
__v: 0
}
}
现在如何在我的 react 组件中显示每首诗的标题和文本。在这里,我只有 2 首诗和诗 id 。但诗歌的数量可能因用户不同而有所差异。所以基本上我需要一种方法将这些诗歌从我的 redux 存储中获取到我的组件中,然后渲染它们。
【问题讨论】:
-
看看react-redux github.com/reactjs/react-redux,特别是connect函数
标签: json reactjs redux react-redux render