将数据从反应钩子传输到对象数组

问题描述

在使用 react-charts 时遇到问题。要绘制图形,您需要一个类似于数据的对象数组:

data: [
  { "x": new Date("2020.03.18"),"y": 60 },{ "x": new Date("2020.03.19"),"y": 23 },{ "x": new Date("2020.03.20"),"y": 23 }
]

我的数据以这种形式存储在反应钩子中:

enter image description here

这是我将钩子拆分为对象数组的失败尝试:

    const initialState = [
        dataCharts.map((units) => {
            {x: new Date(units.y),y: units.x}
        })
    ]

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)