react-navigation

Custom back navigation for reactnavigation back button

与世无争的帅哥 提交于 2019-11-30 13:49:22
How can I give a custom navigation to the header back arrow in ReactNavigation? I want the back arrow in the header to navigate to the screen I define and not to the previous screen. Thanks. You could try 2 things: a) use headerMode: 'none' in your sub-StackRouters instead of your root router (named RouterComponent). Ideally you shouldn't have to do anything more then and the headers of the sub-StackRouters would be displayed in your root router's header. I think I remember something similarly worked a while back for me, but I haven't tested it in a while now and I think it's unlikely that it

Warning: isMounted(…) is deprecated in plain Javascript Classes

不问归期 提交于 2019-11-30 12:58:39
问题 I am implementing 2 screens using react-navigation. But I got the warning below while navigating to the second page: Warning: isMounted(...) is deprecated in plain Javascript Classes. Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks. Versions: react: 16.3.1 react-native: 0.55.2 react-navigation: 1.5.11 util: 0.10.3 Login.js import React, { Component } from 'react'; import { Text, View, Image, TextInput, TouchableOpacity } from

How to Pass Parameters to screen in StackNavigator?

倾然丶 夕夏残阳落幕 提交于 2019-11-30 12:58:03
问题 My React Native code: import React, { Component } from 'react'; import { AppRegistry, ActivityIndicator, StyleSheet, ListView, Text, Button, TouchableHighlight, View } from 'react-native'; import { StackNavigator } from 'react-navigation'; import DetailsPage from './src/screens/DetailsPage'; class HomeScreen extends React.Component { constructor() { super(); const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}); this.state = { userDataSource: ds, }; } componentDidMount(){

React Navigation back() and goBack() not working

前提是你 提交于 2019-11-30 10:58:33
I'm trying to go back two screens. The goal is to go from EditPage to Cover . Here is my navigation stack: Main -> Cover -> EditCover -> EditPage I read the docs and it says to supply a key of the screen you want to go back from, here's my code: this.props.navigation.dispatch(NavigationActions.back({key: 'EditCover'})); I've also tried (with no luck): this.props.navigation.dispatch(NavigationActions.back('EditCover')); this.props.navigation.dispatch(NavigationActions.back({key: 'EditCover'})); this.props.navigation.dispatch(NavigationActions.back({routeName: 'EditCover'})); this.props

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

若如初见. 提交于 2019-11-30 08:11:25
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 from 'react'; import { Button, ScrollView, View, Text, StyleSheet, TouchableHighlight } from 'react

How to Pass Parameters to screen in StackNavigator?

拟墨画扇 提交于 2019-11-30 05:52:15
My React Native code: import React, { Component } from 'react'; import { AppRegistry, ActivityIndicator, StyleSheet, ListView, Text, Button, TouchableHighlight, View } from 'react-native'; import { StackNavigator } from 'react-navigation'; import DetailsPage from './src/screens/DetailsPage'; class HomeScreen extends React.Component { constructor() { super(); const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}); this.state = { userDataSource: ds, }; } componentDidMount(){ this.fetchUsers(); } fetchUsers(){ fetch('https://jsonplaceholder.typicode.com/users') .then((response

Status of React Navigation drawer? (open or closed)

送分小仙女□ 提交于 2019-11-30 04:21:00
问题 I'm building a drawer with React Navigation and want to perform some logic if the user closes the drawer. I don't see anything obvious in the documentation that will allow me to do this. Is anyone aware of a way to do this? 回答1: You need to custom navigation actions to capture the DrawerClose event: const MyDrawerNavigator = DrawerNavigator({ //... }); const defaultGetStateForAction = MyDrawerNavigator.router.getStateForAction; MyDrawerNavigator.router.getStateForAction = (action, state) => {

How to Lock drawer for specific page using drawerNavigation [react-navigation][react-native]

允我心安 提交于 2019-11-30 03:30:48
问题 This is my drawerNavigation : const DashboardStack = StackNavigator({ Dashboard: { screen: Dashboard }, }, { headerMode: 'screen', }); const DetailsformStack = StackNavigator({ Detailsform: { screen: Detailsform }, }, { headerMode: 'none' }); const OtpStack = StackNavigator({ Otp: { screen: Otp, drawer: { lockMode: 'locked-closed' } }, }, { headerMode: 'none' }); const MobilenumberStack = StackNavigator({ Mobilenumber: { screen: Mobilenumber }, }, { headerMode: 'none' }); const

Custom back navigation for reactnavigation back button

泄露秘密 提交于 2019-11-29 18:45:47
问题 How can I give a custom navigation to the header back arrow in ReactNavigation? I want the back arrow in the header to navigate to the screen I define and not to the previous screen. Thanks. 回答1: You could try 2 things: a) use headerMode: 'none' in your sub-StackRouters instead of your root router (named RouterComponent). Ideally you shouldn't have to do anything more then and the headers of the sub-StackRouters would be displayed in your root router's header. I think I remember something

NavigationActions.reset is not a function?

只愿长相守 提交于 2019-11-29 17:17:27
问题 I created a project has a Welcome screen navigate to MainActivity screen. I want that when the user clicks the back button it will close the app in MainActivity not back to Welcome screen. I use the library react-navigation , so I looked for some solution from Github. When I use the code from https://github.com/react-navigation/react-navigation/issues/295. I get the error: NavigationActions.reset is not a function I console.log(NavigationActions); There is no reset obviously. But why can