Skip to content

Instantly share code, notes, and snippets.

@anhducbkhn
Created September 23, 2016 10:27
Show Gist options
  • Select an option

  • Save anhducbkhn/b3a52348c91e2f4534be78cae3927314 to your computer and use it in GitHub Desktop.

Select an option

Save anhducbkhn/b3a52348c91e2f4534be78cae3927314 to your computer and use it in GitHub Desktop.

Revisions

  1. anhducbkhn created this gist Sep 23, 2016.
    67 changes: 67 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,67 @@
    /**
    * 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);