Skip to content

Instantly share code, notes, and snippets.

@Nkzn
Last active May 10, 2017 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nkzn/677a5658ce917c1fe215027bc1b71af0 to your computer and use it in GitHub Desktop.
Save Nkzn/677a5658ce917c1fe215027bc1b71af0 to your computer and use it in GitHub Desktop.
https://reactnavigation.org/ sample for headerless <=> header display. movie: https://twitter.com/Nkzn/status/861952997563092993
import { StackNavigator } from 'react-navigation';
import Login from './login';
import Timeline from './timeline';
const App = StackNavigator({
Login: {
screen: Login,
},
Timeline: {
screen: Timeline,
}
});
export default App;
import { AppRegistry } from 'react-native';
import App from './src/app';
AppRegistry.registerComponent('Sample', () => App);
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
Button
} from 'react-native';
export default class extends Component {
static navigationOptions = {
header: null
};
_onPressLogin() {
this.props.navigation.navigate('Timeline');
}
render() {
return (
<View style={styles.container}>
<Button
onPress={() => this._onPressLogin()}
title="Login"
color="#841584" />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
});
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
Button
} from 'react-native';
import {
NavigationActions
} from 'react-navigation'
export default class extends Component {
static navigationOptions = {
title: "Timeline"
};
_onPressBack() {
this.props.navigation.dispatch(NavigationActions.back());
}
render() {
return (
<View style={styles.container}>
<Text>Timeline</Text>
<Button
onPress={() => this._onPressBack()}
title="Back"
color="#841584" />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment