을 마친 후 반작용 네이티브 ActivityIndicator 내가 레이아웃에 로드 가져 오는 동안 보여줍니다 componentDidMount이 발사 될 때 바퀴가 사라지지만 계속 ActivityIndicator 및 빈 블록 공간이 숨기지 않습니다. 이 구성 요소를 분리하는 방법을 추측하고 있지만 나에게 도움이되는 모든 것이 있습니다.애니메이션
것은 내가 현재이 버전 함께 일하고 있어요 :
import React, { Component } from 'react';
import {
StyleSheet,
View,
... // Couple more components here
ActivityIndicator,
} from 'react-native';
import NewsList from './NewsList';
export default class HomeView extends Component {
constructor(props) {
super(props);
this.state = {
noticias: [],
animating: true,
};
}
componentDidMount(){
fetchFunction() // My fetch function here
.then(data => this.setState({ data:data }))
this.state.animating = false
}
render() {
return (
<View>
<NewsList data={data} /> // My custom component
<ActivityIndicator
animating={this.state.animating}
style={[{height: 80}]}
color="#C00"
size="large"
hidesWhenStopped={true}
/>
</View>
);
}
}
PS :
이react-native-cli: 2.0.1
react-native: 0.40.0
이 내가 사용하고 코드의 일부입니다 내가 돌아 오는을 사용하지 않는. 당신이 당신의 구성 요소를 다시 렌더링하려면
ActivityIndicator with animation working fine The empty space when animating is set to false
'this.state.animating = false' 왜 세트를 사용하지 않았습니까? 이전 줄의 상태? – RRikesh
나는 '.then (data => this.setState ({data : data, animating : false}))' 과 같은 결과를 얻었습니다. – vtisnado