简体   繁体   English

输入'{percentage:number; }'不能为CircularProgressbar分配React Typescript

[英]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.

相关问题 反应,typescript “数字”类型的参数不可分配给“ChangeEvent”类型的参数<htmlinputelement> '</htmlinputelement> - react, typescript Argument of type 'number' is not assignable to parameter of type 'ChangeEvent<HTMLInputElement>' TextArea 中的 React Typescript 错误:类型“字符串”不可分配给类型编号 - React Typescript error in TextArea : Type 'string' is not assignable to type number React Typescript:'{ [x: number]: any; 类型的参数 }' 不可分配给类型的参数 - React Typescript: Argument of type '{ [x: number]: any; }' is not assignable to parameter of type 使用TypeScript进行反应:类型“ {}”不可分配给类型 - React with TypeScript: Type '{}' is not assignable to type React Typescript不可分配给type参数 - React typescript is not assignable to parameter of type 类型不可分配(React + Typescript + Firebase) - Type not assignable (React + Typescript + Firebase) Typescript 错误:: 类型“数字”不可分配给类型“从不” - Typescript error :: Type 'number' is not assignable to type 'never' TypeScript错误:类型“…”不能分配给类型“ IntrinsicAttributes&Number” - TypeScript error : Type '…' is not assignable to type 'IntrinsicAttributes & Number' 与 TypeScript 反应:类型不可分配给类型“IntrinsicAttributes” - React with TypeScript: Type is not assignable to type 'IntrinsicAttributes' 无效类型不能分配给布尔类型(反应/打字稿) - Type Void is Not Assignable to Type Boolean (React/Typescript)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM