Skip to content

Instantly share code, notes, and snippets.

@fselcukcan
Created November 7, 2015 07:48
Show Gist options
  • Save fselcukcan/2a098924dfe3bbee51d4 to your computer and use it in GitHub Desktop.
Save fselcukcan/2a098924dfe3bbee51d4 to your computer and use it in GitHub Desktop.
Navigator with renderScene
'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