onConnectionClose () { this.setState({ status: States.DISCONNECTED, }); // reconnect mechanics this.state.interval = setInterval(() => { if (this.state.status === States.CONNECTING || this.state.status === States.CONNECTED) { clearInterval(this.state.interval); return; } this.connect(); }, 1000); }
componentDidMount(){ const { setParams } = this.props.navigation const colors = ['red', 'orange', 'yellow', 'green', 'blue', 'cyan'] let i = 0 setInterval(() => { if (i >= colors.length) i = 0 const color = colors[i++] setParams({color}) }, 100) }
componentDidMount() { AppState.addEventListener('change', nextAppState => { if (nextAppState === 'active') { this.interval = setInterval(this.refresh, 1000); } else { clearInterval(this.interval); } }); this.interval = setInterval(this.refresh, 1000); }
constructor(props) { super(props); interval = setInterval(function() { this.setState({time: new Date().toLocaleString()}); }.bind(this), 1000); }
componentDidMount() { setInterval(() => { this.setState({ count: this.state.count + 1 }); }, 1000) }
componentDidMount() { this.props.getAssets() // Get assets this.getData() this.timer = setInterval(() => this.getData(false), 10000) // Refresh data every 10 seconds }
setInterval(() => { if (this.state.progress >= 1) { clearInterval(this.timeOut); } else { this.setState({ progress: this.state.progress + 0.02, }); } }, 100)
componentDidMount() { let timer = setInterval(this.timer, 10); this.setState({ timer }); // this.loadData() }
setInterval(() => { this.setState(previousState => { return { isBlink: !previousState.isBlink }; }); }, 1000)
componentDidMount() { setInterval(() => { this.setState({ time: new Date().toLocaleString().split(',')[0], }); }) }
componentDidMount() { // Update countdown timer every second this.intervalId = setInterval(() => { this.setState({ duration: this.getDurationFromNow(), }); }, 1000); }
constructor(props) { super(props); this.state = { showText: true }; setInterval(() => { this.setState({ showText: !this.state.showText }); }, 1000); }
componentDidMount() { //Toggles the state every second setInterval(() => ( this.setState(previousState => ( { isShowingText: !previousState.isShowingText} )) ), 2000); }
componentDidMount(){ this.intval=setInterval(()=>{ this.setState({timer:this.state.timer-1}) },1000) }
componentWillMount(){ setInterval(()=> { this.setState({count: this.state.count + 1}) }, 1000 ) }