重新图表更新到 v2.x.x 后,PieChartProps 消失了

问题描述

我使用 recharts v1.8.5 / @types/recharts v1.8,19 创建了图表。我想升级到最新版本的recharts(v2.0.8),但内部类型似乎还没有准备好。 Typescript 编译器抱怨 PieChartProps 不再从包 recharts 导出。

从捆绑的类型定义中导出饼图:

types/index.d.ts

export { PieChart } from './chart/PieChart';

types/chart/PieChart.d.ts

/// <reference types="react" />
export declare const PieChart: {
    new (props: import("./generateCategoricalChart").CategoricalChartProps): {
        uniqueChartId: any;
        ...
    }
}

所以 PieChart 似乎对它的 Props 有定义。但是我如何在我自己的组件中使用它呢?我试过了

// not working
import { CategoricalChartProps } from 'recharts/generateCategoricalChart'


// not working
import { Props } from 'recharts/types/chart/PieChart'

--- 更新---

这有效,但看起来有点难看(不清楚它是 PieChartProps)。有没有更好的办法?

import { CategoricalChartProps } from 'recharts/types/chart/generateCategoricalChart'

解决方法

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

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

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...