import React, { Component } from 'react'; import { StyleSheet, View, Button } from 'react-native'; import ProgressBar from './ProgressBar'; export default class Progressable extends Component { static navigationOptions = { title: 'ProgressBar Example', }; state = { progress: 0, visible: true, }; fetchData = () => { let progress = 0; if (this.timeout) { clearTimeout(this.timeout); } this.timeout = setInterval(() => { this.setState({ progress, }); progress += 0.1; if (progress > 1) { clearInterval(this.timeout); } }, 1000); }; componentDidMount() { this.fetchData(); } render() { return ( {this.state.visible && ( )}