react-navigation

React Navigation - Gradient color for Header

不打扰是莪最后的温柔 提交于 2019-11-29 07:28:18
问题 I am using React Navigation in React Native app and i want to change the backgroundColor for the header to be gradient and i found out there is a node module : react-native-linear-gradient to achieve gradient in react native i have Root StackNavigator like that : const Router = StackNavigator({ Login: { screen: Login, navigationOptions: ({navigation}) => ({ headerTitle: <Text>SomeTitle</Text> headerLeft: <SearchAndAgent />, headerRight: <TouchableOpacity onPress={() => { null } <

Getting undefined is not an object evaluating _this.props.navigation

北慕城南 提交于 2019-11-29 05:12:11
问题 I'm using DrawerNavigator and I have 3 pages: Router page , mainScreen and a photos page , I maked a header navbar area and I used This <TouchableHighlight onPress={() => this.props.navigation.navigate('DrawerOpen')}> to open Drawer menu in mainScreen and used that for photos page too, menu is ok in mainScreen, But when I click <TouchableHighlight onPress={() => this.props.navigation.navigate('DrawerOpen')}> in photos page, I got this error: How Can I fix That? My photos page: import React

React Navigation: Navigate Back To Root using NavigationActions.reset, goBack and getStateForAction

爱⌒轻易说出口 提交于 2019-11-29 01:57:25
问题 Say I've navigated through 4 screens in my StackNavigator App and now I want to go back to the first screen. There seems to be three different ways to do this and they do navigate to where I want to do, however each way has an animation that cycles through each previous screen. Is there a clean way to navigate from SCREEN_D to SCREEN_A ? In other words, I don't want to see SCREEN_C and SCREEN_B a split of a second before seeing SCREEN_A when navigating backwards from SCREEN_D navigation

react-navigation: Detect when screen, tabbar is activated / appear / focus / blur

血红的双手。 提交于 2019-11-29 01:08:50
Perviously when I wanted to make some actions when screen is opened I put them inside componentDidMount. For example I can fetch some data. like this. componentDidMount() { this.updateData(); } But with react-navigation componentDidMount occurs only one time when user open screen first time, and if later user open this page again it will not trigger componentDidMount. What is proper way to detect when page(screen) is activated and do actions? With react-navigation , you can do that. Add listeners in componentDidMount or componentWillMount this.subs = [ this.props.navigation.addListener(

React-native/react-navigation: how do I access a component's state from `static navigationOptions`?

爱⌒轻易说出口 提交于 2019-11-28 23:23:11
How do you handle cases when you have, say, a form component, and you need to submit a part of the component's state using button in navigation bar? const navBtn = (iconName, onPress) => ( <TouchableOpacity onPress={onPress} style={styles.iconWrapper} > <Icon name={iconName} size={cs.iconSize} style={styles.icon} /> </TouchableOpacity> ) class ComponentName extends Component { static navigationOptions = { header: (props) => ({ tintColor: 'white', style: { backgroundColor: cs.primaryColor }, left: navBtn('clear', () => props.goBack()), right: navBtn('done', () => this.submitForm()), // error:

React Navigation; use image in header?

落花浮王杯 提交于 2019-11-28 19:54:20
I'm using react navigation in a react native project and I want to customize the header with an image. For a color I can use simple styling, but since react native doesn't support background images I need a different solution. Update: Since v2 of the library there's an special option for setting the header background, namely headerBackground . This option accepts a React component, so when set to an Image component, it will use that. For example: export default createStackNavigator({ Home: { screen: HomeScreen }, }, { navigationOptions: { headerBackground: ( <Image style={StyleSheet

How to get a height of a Keyboard in React-Native?

风流意气都作罢 提交于 2019-11-28 19:14:05
I am using React-Navigation in my app and the app consists of StackNavigator with multiple screens, some screens of which have TextInput with autoFocus={true} Problem: on these screens when the component renders, the height of the screen is being set in the constructor: constructor(props) { super(props); this.state = { height: Dimensions.get('window').height, }; } But, since the autoFocus of TextInput is true , the keyboard on this screen pops-up on the screen almost instantly after the render , causing the component to re-render due to the eventListener that is added to Keyboard in

Disable back button in react navigation

被刻印的时光 ゝ 提交于 2019-11-28 16:48:32
I'm using react native navigation (react-navigation) StackNavigator. it starts from the Login page throughout the whole lifecycle of the app. I don't want to have a back option, returning to the Login screen. Does anyone know how it can be hidden on the screen after the login screen? BTW, I'm also hiding it in the login screen by using: const MainStack = StackNavigator({ Login: { screen: Login, navigationOptions: { title: "Login", header: { visible: false, }, }, }, // ... other screens here }) For react-navigation version v2 or newer to make the back button disappear: navigationOptions: {

How to create a Drawer Component and adding it to multiple screens

你离开我真会死。 提交于 2019-11-28 13:09:55
Hi i want to create a component by using a createDrawerNavigator , and want to add it all screens could you help me. In the below example don't copy all the syntax understand the concept from my explanation I have configured redux and many other imports you may not need so configure and include content in below files as you need. File name - BurgerMenu.js import React, { Component } from "react"; import SideBar from "./SideBar.js"; import News from "../../Containers/News"; // import your screens instead import Copyright from '../../Containers/Gallery' // import your screens instead import {

How to handle exit app in one screen not in the whole app - React Native?

别等时光非礼了梦想. 提交于 2019-11-28 09:22:02
问题 I have some issue with BackHandler , the issue is when running the app and go to the let's say Sign Up screen and touch the back in my mobile they will run the function and show the Alert to confirm, but now when I go to any other screen and touch the back they will I need to just back to the previous screen on every back BackHandler.exitApp(); runs, Although I write if the routname is SignUp just exit the app not other screens this is my code Sign Up import React from "react"; import { Text,