[英]Type '{ percentage: number; }' is not assignable React Typescript for the CircularProgressbar
Hi I am going to use the React CircularProgressbar in my application. 嗨,我将在我的应用程序中使用React CircularProgressbar。 I followed the step as mentioned in the below link.
我按照以下链接中提到的步骤进行操作。
https://github.com/kevinsqi/react-circular-progressbar https://github.com/kevinsqi/react-circular-progressbar
I am creating the component using the Typescript , But I am getting the error and code as below. 我正在使用Typescript创建组件 ,但我收到错误和代码如下。 Great appreciate.
非常感谢。
import * as React from 'react';
import CircularProgressbar from 'react-circular-progressbar';
import 'react-circular-progressbar/dist/styles.css';
export default function CircularProgressBar(props: {percentageVal: number, textVal: string}) {
return (<div>
<CircularProgressbar
percentage={props.percentageVal}
text={props.textVal}
/>
</div>);
}
Error: semantic error TS2322 Type '{ percentage: number; 错误: 语义错误TS2322类型'{百分比:数字; text: string;
text:string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly' .
''不能赋值为'IntrinsicAttributes&IntrinsicClassAttributes&Readonly' 。
I'm the author of react-circular-progressbar - sorry you're running into issues. 我是react-circular-progressbar的作者 - 抱歉,你遇到了问题。 Based on the props, I assume you're on version 1.xx of react-circular-progressbar?
根据道具,我假设你在反应循环进度栏的1.xx版本?
Here's a react + typescript CodeSandbox which uses v1.2.1, and does compile with the code you're using without the same error: https://codesandbox.io/s/reactcircularprogressbar-stackoverflow-56038279-v121-cris9 这是一个使用v1.2.1的react + typescript CodeSandbox,并使用您正在使用的代码进行编译而没有相同的错误: https ://codesandbox.io/s/reactcircularprogressbar-stackoverflow-56038279-v121-cris9
Could you reproduce the error in a CodeSandbox or a small typescript create-react-app repo? 你能在CodeSandbox或一个小打字稿create-react-app repo中重现错误吗? Would be really helpful for diagnosing the issue.
对诊断问题非常有帮助。 You could also try updating to v2.0.0.
您也可以尝试更新到v2.0.0。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.