Last active
January 9, 2018 11:25
-
-
Save lucas1richard/605af948f77b5599c6c587da272c5cb1 to your computer and use it in GitHub Desktop.
react-navigation stack headings
This file contains 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 { connect } from 'react-redux'; | |
import Text from 'components/Text'; | |
import { View } from 'react-native'; | |
import { Field, reduxForm } from 'redux-form/immutable'; | |
import { NAV_SCREEN_OPTIONS } from 'constants'; | |
import { FIRST_LAST_NAME } from '../../routes'; | |
export class EmailPassword extends Component { | |
static navigationOptions = ({ screenProps }) => ({ | |
...NAV_SCREEN_OPTIONS, | |
title: 'Create Account', | |
headerLeft: <Text style={{ color: '#fff' }} onPress={() => screenProps.parentNav.goBack(screenProps.parentNav.state.key)}>←</Text> | |
}); | |
render() { | |
return ( | |
<View> | |
{/*...*/} | |
</View> | |
); | |
} | |
} | |
export default EmailPassword; |
This file contains 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 SignupRoutes from './routes'; | |
export class Signup extends Component { | |
static navigationOptions = () => ({ | |
header: null | |
}); | |
render() { | |
return ( | |
<SignupRoutes parentNav={this.props.navigation} /> | |
); | |
} | |
} | |
export default Signup; |
This file contains 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 from 'react'; | |
import { View, Text } from 'react-native'; | |
import { StackNavigator } from 'react-navigation'; | |
import EmailPassword from './containers/EmailPassword'; | |
import FirstLastName from './containers/FirstLastName'; | |
export const EMAIL_PASSWORD = 'EMAIL_PASSWORD'; | |
export const FIRST_LAST_NAME = 'FIRST_LAST_NAME'; | |
const SignupNav = StackNavigator({ | |
EMAIL_PASSWORD: { screen: EmailPassword }, | |
FIRST_LAST_NAME: { screen: FirstLastName } | |
}, { | |
initialRouteName: EMAIL_PASSWORD | |
}); | |
class Signup extends React.Component { | |
static navigationOptions = { | |
title: 'Signup Screen' | |
} | |
render() { | |
return ( | |
<View style={{ flex: 1 }}> | |
<SignupNav screenProps={{ parentNav: this.props.parentNav }} /> | |
</View> | |
); | |
} | |
} | |
export default Signup; |
This file contains 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 { StackNavigator } from 'react-navigation'; | |
import LaunchScreen from 'containers/LaunchScreen'; | |
import Login from 'containers/Login'; | |
import Signup from 'containers/Signup'; | |
import { LAUNCH_SCREEN } from 'screens'; | |
const PrimaryNav = StackNavigator({ | |
LAUNCH_SCREEN: { screen: LaunchScreen }, | |
LOGIN: { screen: Login }, | |
SIGNUP: { screen: Signup } | |
}, { | |
initialRouteName: LAUNCH_SCREEN | |
}); | |
export default PrimaryNav; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
App/routes.js
contains the primary application navigation used from the beginningApp/containers/Signup/routes.jsx
navigation is to be nested within the primary navigationPut the nested navigation within a screen accessible to the primary navigation, and set
header: null
. Pass the primary navigation object down asscreenProps
and use it in theinitialRouteName
of the nested navigation