diff --git a/releases/next/docs/activityindicator.html b/releases/next/docs/activityindicator.html index 9decabc8fb6..f90f3cbf64c 100644 --- a/releases/next/docs/activityindicator.html +++ b/releases/next/docs/activityindicator.html @@ -4,34 +4,43 @@ ]) #

Size of the indicator (default is 'small'). Passing a number to the size prop is only supported on Android.

ioshidesWhenStopped PropTypes.bool #

Whether the indicator should hide when not animating (true by default).

Examples #

Edit on GitHub
'use strict'; -const React = require('react'); -const ReactNative = require('react-native'); -const { - ActivityIndicator, - StyleSheet, - View, -} = ReactNative; -const TimerMixin = require('react-timer-mixin'); +import React, { Component } from 'react'; +import { ActivityIndicator, StyleSheet, View } from 'react-native'; -const ToggleAnimatingActivityIndicator = React.createClass({ - mixins: [TimerMixin], +/** + * Optional Flowtype state and timer types definition + */ +type State = { animating: boolean; }; +type Timer = number; - getInitialState() { - return { +class ToggleAnimatingActivityIndicator extends Component { + /** + * Optional Flowtype state and timer types + */ + state: State; + _timer: Timer; + + constructor(props) { + super(props); + this.state = { animating: true, }; - }, - - setToggleTimeout() { - this.setTimeout(() => { - this.setState({animating: !this.state.animating}); - this.setToggleTimeout(); - }, 2000); - }, + } componentDidMount() { this.setToggleTimeout(); - }, + } + + componentWillUnmount() { + clearTimeout(this._timer); + } + + setToggleTimeout() { + this._timer = setTimeout(() => { + this.setState({animating: !this.state.animating}); + this.setToggleTimeout(); + }, 2000); + } render() { return ( @@ -42,7 +51,9 @@ const ToggleAnimatingActivityIndicator = Rea /> ); } -}); +} + + exports.displayName = (undefined: ?string); exports.framework = 'React';