I have an ActivityIndicator that is displayed during fetch loading, and the wheel disappears when componentDidMount starts , but it also keeps the block space in the layout blank. I guess how to unmount this component, but everything works for me.
I am currently working with these versions:
react-native-cli: 2.0.1
react-native: 0.40.0
This is part of the code I'm using:
import React, { Component } from 'react';
import {
StyleSheet,
View,
...
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()
.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: I do not use Redux.
ActivityIndicator with great animation.
Empty space when animation is set to false.
source
share