react-navigation

React Native - How to open route from push notification

痞子三分冷 提交于 2020-06-24 07:19:14
问题 I'm using react-navigation and react-native-push-notification . How can I open a certain StackNavigator's screen in onNotification callback? Should work when: app is closed app is in the foreground app is in the background I only need it working in Android for now. I've tried to pass a callback function to notification in my component: _handleClick() { PushNotification.localNotification({ foreground: false userInteraction: false message: 'My Notification Message' onOpen: () => { this.props

React Navigation V5 Hide Bottom Tab in Specific Screens

风流意气都作罢 提交于 2020-06-23 14:15:07
问题 I am creating a React Native app using React Navigation version 5, and I have a bottom tab navigator with a stack navigator nested inside each screen of the tab navigator. I only want the bottom tab bar to show when on the first page of each stack navigator. Here is a snack that displays my app's basic navigation functionality: https://snack.expo.io/@brforest/hide-tab-1. Per the bottom tab documentation, there is a tabBarVisible options attribute, but: Hiding tab bar can cause glitches and

Navigation between Screens but constructor is not calling

ε祈祈猫儿з 提交于 2020-06-17 15:16:31
问题 I have multiple screens in my app, I used CreatStackNavigator for navigation. If I visit the screen second time the constructor is not getting called. Let suppose I have four screen A,B,C & D and currently I am at A. Then I go to C and then D screens respectively. Now if I clicked on C again then the constructor of C is not getting called. I used ComponentReceivedMount() also but it didn't worked. My code is :- constructor(props) { super(props); ToastAndroid.show('heeeelll', ToastAndroid.LONG

React Native - Android - keyboardavoidingView in stackNavigator within a tabNavigator pushes bottomTabBar (clunky behaviour)

≡放荡痞女 提交于 2020-06-17 09:37:08
问题 I am trying to build an auth flow that has a welcome page and then login or signup depending on the user's case. It is built inside a stack navigator. The first screen has no header but then login and signup do via their screen options. // AuthNavigator const AuthStackNavigator = createStackNavigator(); export const AuthNavigator = () => { return ( <AuthStackNavigator.Navigator initialRouteName={WELCOME_PAGE.id} screenOptions={{ headerShown: false, headerTintColor: colors.primary, }} lazy>

Updating State of Another Screen in React Navigation

半城伤御伤魂 提交于 2020-06-13 07:08:12
问题 import { createStackNavigator, createDrawerNavigator } from 'react-navigation' import { Button, Text } from 'react-native' import React, { Component } from 'react' // Components class Home extends Component { constructor(props) { super(props) this.state = {value: 1} } render() { return (<Text>{this.state.value}</Text>) } } class Settings extends Component { _press = function () { // Update Home's state here } render() { return (<Button title='Update Home' onPress={this._press.bind(this)}><

Updating State of Another Screen in React Navigation

穿精又带淫゛_ 提交于 2020-06-13 07:02:43
问题 import { createStackNavigator, createDrawerNavigator } from 'react-navigation' import { Button, Text } from 'react-native' import React, { Component } from 'react' // Components class Home extends Component { constructor(props) { super(props) this.state = {value: 1} } render() { return (<Text>{this.state.value}</Text>) } } class Settings extends Component { _press = function () { // Update Home's state here } render() { return (<Button title='Update Home' onPress={this._press.bind(this)}><

What is a difference between navigation.navigate(), navigation.push(), navigation.goBack() and navigation.popToTop() if I go back from page to page?

…衆ロ難τιáo~ 提交于 2020-06-11 10:44:00
问题 From this and this, I learned that there is a meaningful difference between navigation.navigate() and navigation.push() . Nevertheless, I am still wondering if I can use navigation.navigate() or navigation.push() instead of navigation.goBack() or navigation.popToTop() . In my case, there is one page, and some parameters are included in the navigation. (i.e, through navigation.navigate(param, {...}) or navigation.push(param, {...}) . Once I move to another page, some change in variable

What is a difference between navigation.navigate(), navigation.push(), navigation.goBack() and navigation.popToTop() if I go back from page to page?

大兔子大兔子 提交于 2020-06-11 10:43:02
问题 From this and this, I learned that there is a meaningful difference between navigation.navigate() and navigation.push() . Nevertheless, I am still wondering if I can use navigation.navigate() or navigation.push() instead of navigation.goBack() or navigation.popToTop() . In my case, there is one page, and some parameters are included in the navigation. (i.e, through navigation.navigate(param, {...}) or navigation.push(param, {...}) . Once I move to another page, some change in variable

React-navigation: How to set initialParams for screen based on condition?

冷暖自知 提交于 2020-06-09 05:29:28
问题 I have BottomTabsNavigator as part of StackNavigator . When I launch the app, I need to pass initialParams in Home tab based on a condition in BottomTabsNavigator . Apparently, BottomTabsNavigator is rendered once only and initialParams always sends default value instead of new value based on condition. <Tab.Screen name="Home" component={HomeScreen} options={{ title: 'Home', tabBarIcon: 'home-outline', tabBarLabel: 'Home', }} initialParams={{ 'tappedNotification1': notificationOpened }} // <-

useTheme equivalent for class component

强颜欢笑 提交于 2020-06-01 05:13:05
问题 I would like to use the current theme in my class component. According to the latest (RN 5.x) documentation, there is a useTheme() hook for that purposes. However, it doesn't mention any class equivalent. I found ThemeContext.Consumer in RN 4.x but it is not available in 5.x anymore. Is it possible to achieve the effect of useTheme() in some other way for a class component? 回答1: This is not so elegant, but it will do the job for you. Here is my method to access the theme inside a class