Last active
October 6, 2016 16:08
-
-
Save jjgonecrypto/d4b97d126dc11781bf72c2f0b03847e8 to your computer and use it in GitHub Desktop.
Navigator in react-native
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 Start from './Start' | |
| import NextPage from './NextPage' | |
| const Views = { Start, NextPage } | |
| <Navigator | |
| initialRoute={{ view: 'Start' }} | |
| renderScene={(route, navigator) => { | |
| const SceneComponent = Views[route.view]; | |
| return <SceneComponent {...route.props} navigator={navigator} />; | |
| }} | |
| /> |
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
| export default class Start extends Component { | |
| onPress() { | |
| this.props.navigator.push({ view: 'NextPage', props: { ... } }); // add props if required | |
| // If in NextPage you want to go "back", you'd do | |
| // this.props.navigator.pop(); | |
| } | |
| render() { | |
| <TouchableHighlight onPress={this.onPress.bind(this)}>Test</TouchableHighlight> | |
| } | |
| } | |
| Start.propTypes = { | |
| navigator: PropTypes.object.isRequired | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment