Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧐[问题] chartRef和ref使用ts该如何定义? #43

Closed
zhangyu1818 opened this issue May 27, 2020 · 5 comments
Closed

🧐[问题] chartRef和ref使用ts该如何定义? #43

zhangyu1818 opened this issue May 27, 2020 · 5 comments
Assignees

Comments

@zhangyu1818
Copy link

🧐 问题描述 [详细地描述问题,让大家都能理解]

组件的chartRef和ref的定义好像没有导出,该如何定义?

💻 示例代码 [如果有必要,展示代码,线上示例,或仓库]

🚑 其他信息 [如截图等其他信息可以贴在这里]

@xiaohuoni
Copy link
Member

const chartRef = useRef<ChartProp>(null);

@zhangyu1818
Copy link
Author

const chartRef = useRef<ChartProp>(null);

ChartProp是哪里导出的呢,我只找到了图表的xxxConfig

@lxfu1
Copy link
Member

lxfu1 commented May 28, 2020

chartRef 就是 React 的ref , 参考: https://charts.ant.design/guide#%E8%8E%B7%E5%8F%96-chart-%E5%AE%9E%E4%BE%8B

@zhangyu1818
Copy link
Author

chartRef 就是 React 的ref , 参考: https://charts.ant.design/guide#%E8%8E%B7%E5%8F%96-chart-%E5%AE%9E%E4%BE%8B

  const statisticsPlot = useRef();
  statisticsPlot.current?.changeData(statistics);
  // TS2339: Property 'changeData' does not exist on type 'never'.

我在ant design pro里使用,如果不标识useRef的类型不是会报错吗
想知道有没有类似userRef<G2plotBar>()这样的定义,现在我是用infer取的config里的chartRef定义

@xiaohuoni
Copy link
Member

const chartRef = useRef<ChartProp>(null);

ChartProp是哪里导出的呢,我只找到了图表的xxxConfig

AreaConfig 就是 Prop 直接应该没有问题,我写的只是伪代码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants