【发布时间】:2021-02-21 02:19:21
【问题描述】:
我必须将数据从 json 文件放到我的 reducer。 映射此文件后,我得到了一个对象,其中包含我需要的数据。
export const datas = data.properties.map(data => (<store key={Math.floor(Math.random()*1234)} author={data.value} comment={data.group} rate={data.type} />));
this is console log, I just need props from this
如何获得正常的反应表,而不是减速器状态不接受的对象? 或者如何将它实现到减速器状态以获得我需要的效果? 我很抱歉提出愚蠢的问题,我希望你能帮助我:)
【问题讨论】:
-
我很乐意提供帮助,但我真的完全不明白你的问题。您可以编辑您的帖子以包含整个组件吗?
-
您在 console.log 中看到的是
array的store元素。props是您传递给每个<store/>的道具:author、comment和rate。 -
这是你想要的吗?
export const datas = data.properties.map(data =>({author: data.value, comment: data.group, rate: data.type})); -
是的!非常感谢,我真的很感激,祝你有美好的一天:)
标签: json reactjs react-redux