Skip to content

Instantly share code, notes, and snippets.

@anhducbkhn
Created September 23, 2016 10:27
Show Gist options
  • Save anhducbkhn/b3a52348c91e2f4534be78cae3927314 to your computer and use it in GitHub Desktop.
Save anhducbkhn/b3a52348c91e2f4534be78cae3927314 to your computer and use it in GitHub Desktop.
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component, PropTypes } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Image,
TextInput,
NavigatorIOS,
TouchableHighlight
} from 'react-native';
// import MyScene from './MyScene';
class AwesomeProject extends Component {
render() {
return (
<NavigatorIOS
initialRoute={{
component: MyScene,
title: 'My Initial Scene',
}}
style={{flex: 1}}
/>
);
}
}
class MyScene extends Component
{
constructor(props, context) {
super(props, context);
this._onForward = this._onForward.bind(this);
}
_onForward() {
this.props.navigator.push({
title: 'Scene ' + nextIndex,
});
}
render() {
return (
<View style={{backgroundColor: '#DAF6FF'}}>
<Text>Current Scene: { this.props.title }</Text>
<TouchableHighlight onPress={this._onForward}>
<Text>Tap me to load the next scene</Text>
</TouchableHighlight>
</View>
)
}
}
MyScene.propTypes = {
title: PropTypes.string.isRequired,
navigator: PropTypes.object.isRequired,
};
MyScene.defaultProps = {
title: '11'
};
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment