首页 > 解决方案 > react-native-progress-circle 在 android 设备上没有进展

问题描述

我在我的应用程序中使用 react-native-progress-circle 它没有在 android 设备的进度条中显示进度,在 ios 中工作正常

 constructor(props) {
    super(props);

    this.state = {
      progress: 100,
      fadeAnim: new Animated.Value(0),
      percent: 100
    };
  }
  Progress() {
    timeLeft = this.props.data.time_left;
    totalTime = this.props.data.total_time;
    if (interval) {
      clearInterval(interval);
    }
    interval = setInterval(() => {
      timeLeft = timeLeft - 1;
      console.log(timeLeft,"time" )
      const percentageLeft = (timeLeft / totalTime) * 100;
      this.setState({ progress: parseInt(percentageLeft) }, () => {
        console.log(this.state.progress,"pro")
      });
      if (percentageLeft <= 1) {
        clearInterval(interval);
      }
    }, 1000);
  }
  componentDidMount() {
    console.log("object!!!")
    this.Progress();
    setInterval(() => {
      console.log(this.state.percent,'one more interval')
      this.setState({ percent: 50}, ()=> {console.log("fghfg")})
    }, 1000);
    
  }
  componentDidUpdate(prevProps) {
    if (prevProps.socket.checkin_users !== this.props.socket.checkin_users) {
      this.Progress();
    }
  }
  <ProgressCircle
            percent={this.state.progress}
            radius={20}
            borderWidth={4}
            color="#3399FF"
            shadowColor="#eee"
            bgColor="#fff"
          >
            <Svg  width={40} height={30}>
            <Image
              source={{
                uri: renderImage(this.props.data.profile_image, "user"),
              }}
              style={styles.image}
            />
            </Svg>
            
          </ProgressCircle>  



this my code, anyone has any solution? trying from past 2 days can't find anything 

标签: react-nativereact-native-android

解决方案


引用不能很好地使用它react-native-progress的本机ART模块可能是一个问题。react-native

您可以尝试使用 -Link 安装 yarn add @react-native-community/art社区版本

然后清理重建cd android && ./gradlew clean


推荐阅读