react-navigation

How to replicate onDidBlur or onWillBlur with React Navigation 5?

限于喜欢 提交于 2021-01-01 17:53:09
问题 As they point out in the docs, they've gotten rid of the 4 navigation event listeners and instead decided to use Lifecycle events. But the problem I'm running into with React Navigation 5 is that the blur event doesn't work as I need it to! Before, I could add an onWillBlur listener, and do stuff when the user temporarily leaves (not closes) the app (such as close a socket connection, and then reopen it when the user reenters the app). How can I replicate the onWillBlur or onDidBlur events

How to replicate onDidBlur or onWillBlur with React Navigation 5?

ぐ巨炮叔叔 提交于 2021-01-01 17:52:27
问题 As they point out in the docs, they've gotten rid of the 4 navigation event listeners and instead decided to use Lifecycle events. But the problem I'm running into with React Navigation 5 is that the blur event doesn't work as I need it to! Before, I could add an onWillBlur listener, and do stuff when the user temporarily leaves (not closes) the app (such as close a socket connection, and then reopen it when the user reenters the app). How can I replicate the onWillBlur or onDidBlur events

How to Navigate from a functional component, from a screen in a tab navigator, where that tab navigator is nested in a parent stack navigator

ε祈祈猫儿з 提交于 2020-12-27 06:33:30
问题 HomeStackNavigator(stack) ---HomeTabsNavigator(Tab) ---FirstTab(stack) ---CreatePost(screen) ---Posts(Tab) ---Following(screen) ---Feed(screen) <----- functional component in here, lets call it component1 ---SecondTab ... ---Screen2 I want to be able to navigate from a functional component in the feed screen to screen 2. I've tried looking at the nested navigation docs in react native docs but no luck. 回答1: You can use the RootNavigation approach: https://reactnavigation.org/docs/navigating

Navigate to the screen when Tab on BottomTabNavigator is pressed

人走茶凉 提交于 2020-12-26 23:23:26
问题 I would like to navigate to the screen when the particular tab on the BottomTabNavigator is pressed. Normally, when the tab is pressed, it navigates to the configured screen automatically. But I don't want to have that behaviour. I want to hide the bottom tab on that screen and provide back feature in the top bar too. I normally use navigation.navigate('routeName') in ReactNavigationStack screens. But I don't know how/where to write this code in the BottomTabNavigator configuration. For

How to “lazy load” tab navigator screens now that lazy has been removed from react-navigation

安稳与你 提交于 2020-12-26 07:23:27
问题 The maintainers of react-navigation have removed 'lazy: true' from the library, causing all tabs to attempt to render at once (and fetches previously controlled by lazy now firing out of order). In order to maintain similar functionality, how do you force a wait on a tab screen to not load or call fetch calls prior to being focused for the first time? 回答1: It seems they did remove it, but have decided to add it back in v 1.1.2 https://github.com/react-navigation/react-navigation/releases/tag

How to implement drawer navigator in each tab?

大城市里の小女人 提交于 2020-12-15 03:36:54
问题 I want to have drawer navigation in each tab and I followed this approach, but it doesn't work when I switch back to the previous tab (maybe some navigation tree issue). As you can see above, the drawer works fine for the first time in each tab, but when I go back to any already navigated tab and try to open the drawer, the drawer doesn't open for that tab but opens up for the just previous tab. I think there's some navigation issue. HomeBottomTab.js Here, I created a Bottom Tab Navigator and

After upgrading to expo SDK 37.0.0 my stackNavigator header doubled in height

倾然丶 夕夏残阳落幕 提交于 2020-12-13 11:25:06
问题 "expo": "^37.0.0", "react-dom": "16.9.0", "react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz", "react-navigation": "^4.0.9", "react-navigation-drawer": "^2.3.3", "react-navigation-stack": "^1.10.3", "react-navigation-tabs": "^2.6.0" I am facing very weird issue. My stackNavigator header is too high. After upgrading to expo 37.0.0 my header bar doubled in height and I cannot return it to normal. Here is my code for stackNavigator: const DashboardStack =

React Navigation TabNavigator: Reset previous tab on tab change

拜拜、爱过 提交于 2020-12-01 09:41:29
问题 I have the following route structure: StackNavigator -StackNavigator -TabNavigator --Tab1 ---Route 1 (Stack) (initial) ---Route 2 (Stack) --Tab2 ---Route 3 (Stack) (initial) ---Route 4 (Stack) When I visit Tab1 -> Route 1 -> Route 2 -> Tab2 and go back to Tab1 , the active route is 2 instead of the initialRoute 1. I'm doing the following: tabBarOnPress: ({ scene }) => { const { route } = scene; const tabRoute = route.routeName; const { routeName } = route.routes[0]; navigation.dispatch

React Navigation TabNavigator: Reset previous tab on tab change

耗尽温柔 提交于 2020-12-01 09:41:27
问题 I have the following route structure: StackNavigator -StackNavigator -TabNavigator --Tab1 ---Route 1 (Stack) (initial) ---Route 2 (Stack) --Tab2 ---Route 3 (Stack) (initial) ---Route 4 (Stack) When I visit Tab1 -> Route 1 -> Route 2 -> Tab2 and go back to Tab1 , the active route is 2 instead of the initialRoute 1. I'm doing the following: tabBarOnPress: ({ scene }) => { const { route } = scene; const tabRoute = route.routeName; const { routeName } = route.routes[0]; navigation.dispatch

react navigation in react native, with conditional stack, and authentication

这一生的挚爱 提交于 2020-11-29 19:26:52
问题 import React, { Component } from 'react' import { Container, Content, Form, Item, Input, Label, Button,Text, Icon} from 'native-base' import AsyncStorage from '@react-native-community/async-storage'; import authStore from '../store/authStore'; export default class Login extends Component { constructor(props){ super(props); this.state={ email:'', password:'' } } handleLogin = async () =>{ let requestObject = { email: this.state.email, password: this.state.password } authStore.userLogin