AnimatedCircularProgress 类型出错

来源:13-3 自定义底部标签按钮(下)

慕粉1454239076

2021-01-07

AnimatedCircularProgress

使用环形组件的时候跟老师使用方法一致,报了一个错,不知道什么原因

报了一个类型不兼容

类型“{ children: Element; }”与类型“IntrinsicAttributes & Pick<ClassAttributes<Progress> & IProps, "ref" | "key">”不具有相同的属性。ts(2559)

使用方法如下

const mapStateToProps = ({player}: RootState) => {
    return {
        currentTime: player.currentTime,
        duration: player.duration
    }
}

const connector = connect(mapStateToProps)

type ModelState = ConnectedProps<typeof connector>

interface IProps extends ModelState {}

class  Progress extends React.PureComponent<IProps> {
    render() {
        const { children,currentTime,duration } = this.props
        const fill =duration ? (currentTime / duration ) * 100 : 0
        return (
            <AnimatedCircularProgress size={40} width={2} tintColor='#f86442' backgroundColor="#ededed" fill={fill}>
                {() => <>{children}</>}
            </AnimatedCircularProgress>
        )
    }
}

调用的时候

<Progress>
      <Animated.View style={[{transform: [{rotate: this.rotate}]}]}>
      {
          thumbnailUrl ? (<Image source={{uri: thumbnailUrl}} />) : (<Icon name="iconplay" color="#ededed" size={40} />)
      }
      </Animated.View>
</Progress>
写回答

2回答

爱学习啦啦啦啦

2021-09-04

跟你报了同一个错误,请问解决了吗


0
0

今朝

2021-01-25

//img.mukewang.com/szimg/600e928a09d2061511840676.jpg

有可能是react版本不同或者ts配置不同的原因

0
0

跨平台应用ReactNative+TypeScript仿喜马拉雅开发App

从入门到实战,掌握用TypeScript开发ReactNative应用

838 学习 · 340 问题

查看课程