问题描述
我在我的应用程序中使用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-native-progress
引用了ART
中的本机react-native
模块,可能无法解决问题。
您可以尝试使用以下命令安装社区版本
yarn add @react-native-community/art
-Link。
然后用cd android && ./gradlew clean
清理重建