Create a gist now

Instantly share code, notes, and snippets.

@dsibiski /Spinner.js
Last active Sep 18, 2015

What would you like to do?
Wrap platform specific components and let the packager do the work. The packager excludes "*.ios.js" files for Android development and vice versa for iOS development.
// Spinner.ios.js
var React = require('react-native');
var {
ActivityIndicatorIOS,
} = React;
class Spinner extends React.Component {
render() {
return (
<ActivityIndicatorIOS
animating={this.props.isLoading}
size='large' />
);
}
}
module.exports = Spinner;
// Spinner.android.js
var React = require('react-native');
var {
ProgressBarAndroid,
View,
} = React;
class Spinner extends React.Component {
render() {
if (this.props.isLoading) {
return (
<View style={{alignItems: 'center'}}>
<ProgressBarAndroid styleAttr="Large"/>
</View>
);
} else {
return ( <View /> );
}
}
}
module.exports = Spinner;
// MyApp.js
var React = require('react-native');
var Spinner = require('./Spinner');
class MyApp extends React.Component {
render() {
return (
<Spinner animating={true}/>
);
}
});
module.exports = MyApp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment