Created
March 23, 2017 18:26
-
-
Save brodeynewman/fbccd68edbd07c7ff31fbe8f2a752453 to your computer and use it in GitHub Desktop.
React Native Navigation Component
This file contains hidden or 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
| import React, { Component } from 'react'; | |
| import { | |
| Text, | |
| View, | |
| TouchableOpacity | |
| } from 'react-native'; | |
| export default class Nav extends Component { | |
| constructor(props) { | |
| super(props) | |
| } | |
| navigateToProp() { | |
| this.props.navigator.push({ | |
| id: this.props.menu | |
| }); | |
| } | |
| render() { | |
| return ( | |
| <View style={styles.nav}> | |
| <TouchableOpacity onPress={this.navigateToProp.bind(this)}> | |
| <Text> | |
| {this.props.menu} | |
| </Text> | |
| </TouchableOpacity> | |
| </View> | |
| ); | |
| } | |
| } | |
| // import Nav | |
| import Nav from './location'; | |
| // Render component, passing in the menu prop and navigator from Navigator | |
| <Nav menu="About" navigator={this.props.navigator}/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment