Last active
September 18, 2015 01:25
-
-
Save dsibiski/d46cf47043d354132dc7 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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