首页 > 解决方案 > 错误:2339 属性“setNativeProps”不存在类型“从不”

问题描述

每当我在我的代码中使用“setNativeProps”时,由于某种原因它不会工作,而且它不仅仅是一个代码。它总是显示错误 2339 并且我正在使用 typescript 我在甜甜圈图上使用带有 expo 的 react.js 这里的代码, PLZ 帮助

    React.useEffect(() =>{
        const maxPerc=100 * percentage/max;
        const strokeDashoffset= circleCircumference - (circleCircumference *maxPerc) /100;
        animatedValue.addListener(v =>{
            if(circleRef?.current){
                circleRef.current.setNativeProps({
                    strokeDashoffset,
                });
            }
        })
    })
    return (
      <View>
          <Svg width={radius * 2}height={radius * 2} viewBox={`0 0 ${halfCircle * 2} ${halfCircle * 2}`}>
              <G rotation='-90 ' origin={`${halfCircle}, ${halfCircle}`}>
                  <Circle
                   cx='50%'
                   cy='50%'
                   stroke={color}
                   strokeWidth={strokeWidth}
                   r={radius}
                   fill="transparent"
                   strokeOpacity={0.2}
                  />
                  <AnimatedCircle
                   ref={circleRef}
                   cx='50%'
                   cy='50%'
                   stroke={color}
                   strokeWidth={strokeWidth}
                   r={radius}
                   fill="transparent"
                   strokeDasharray={circleCircumference}
                   strokeDashoffset={strokeDashoffset}
                   strokeLinecap='round'
                   />
              </G>
          </Svg>
      </View>
    );
}

标签: javascriptreactjstypescriptreact-nativeexpo

解决方案


推荐阅读