Created
November 7, 2015 07:48
-
-
Save fselcukcan/2a098924dfe3bbee51d4 to your computer and use it in GitHub Desktop.
Navigator with renderScene
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
'use strict'; | |
var React = require('react-native'); | |
var { | |
AppRegistry, | |
Navigator, | |
StyleSheet, | |
Text, | |
View, | |
} = React; | |
var NavigationBar= React.createClass({ | |
render: function() { | |
return ( | |
<View style={styles.navbar}> | |
<Text>A</Text> | |
<Text>B</Text> | |
<Text>C</Text> | |
<Text>D</Text> | |
<Text>E</Text> | |
<Text>F</Text> | |
<Text>G</Text> | |
<Text>H</Text> | |
</View> | |
); | |
}, | |
}); | |
var FirstScene = React.createClass({ | |
render: function() { | |
return ( | |
<Text>This is first scene.</Text> | |
); | |
}, | |
}); | |
var SampleApp = React.createClass({ | |
renderScene: function(route) { | |
var Component = route.component; | |
return ( | |
<Component | |
/> | |
); | |
}, | |
render: function() { | |
return ( | |
<Navigator | |
navigationBar={NavigationBar} | |
initialRoute={{component: FirstScene, name: "first scene!", index:0}} | |
renderScene={this.renderScene} | |
/> | |
); | |
}, | |
}); | |
var styles = StyleSheet.create({ | |
navbar: { | |
flex:1, | |
flexDirection: 'row', | |
}, | |
}); | |
AppRegistry.registerComponent('SampleApp', () => SampleApp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment