react-navigation

React-Navigation: navigate from actions file

情到浓时终转凉″ 提交于 2021-02-19 03:58:07
问题 I'm new to RN and JS. I want to navigate once a login action is complete, but I cannot get it to work. I am using firebase. This is from my actions file. It throws a firebase error: export const LOGIN_USER_SUCCESS = 'login_user_success'; export const loginUserSuccess = (dispatch, user) => { dispatch({ type: LOGIN_USER_SUCCESS, payload: user }); this.props.navigation.navigate('groupMain'); // this doesnt work }; I also tried putting it into the Login component - this might be a step in right

React-Navigation: Use/Change header title with Redux state

女生的网名这么多〃 提交于 2021-02-18 20:11:29
问题 Is it possible to access the whole Redux state inside the React Navigation's header title? The official docs says that the state corresponding to the navigation is accessible: static navigationOptions = { title: ({ state }) => `Chat with ${state.params.user}` }; But I wish to access other parts of my Redux state, with the title updating when that state updates. Is that possible today? 回答1: this is possible with a little workaround. I would not even call this a workaround either I would call

Re-render component when navigating the stack with React Navigation

落花浮王杯 提交于 2021-02-18 10:19:14
问题 I am currently using react-navigation to do stack- and tab- navigation. Is it possible to re-render a component every time the user navigates to specific screens? I want to make sure to rerun the componentDidMount() every time a specific screen is reached, so I get the latest data from the server by calling the appropriate action creator. What strategies should I be looking at? I am pretty sure this is a common design pattern but I failed to see documented examples. 回答1: React Navigation

How To Use both 'adjustPan' and 'adjustResize' for 'windowSoftInputMode' in React Native Android app

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-18 08:59:08
问题 How can I use both 'adjustPan' and 'adjustResize' in AndroidManifest.xml react native app. Use Case My navigation is made upon ReactNavigation with StackNavigator and TabNavigator. I have a text box where the user can type any data. While performing this, the tab bar is displaying on the top of Keyboard. In order to block this i used 'adjustPan' and it worked fine. On another screen, I have a registration with multiple text boxes. Here I cant scroll the entire screen unless and clicking 'tick

Change status bar color with react-navigation

余生颓废 提交于 2021-02-17 19:33:10
问题 I use a DrawerNavigator from react-navigation in my app. Without any customization, the Android status bar is blue, and not black. I tried to do StatusBar.setBackgroundColor('#000000'); but it only works for a few seconds, and then it goes back to blue. It seems that something I am using set the status bar color to blue. However, I tried to remove all dependencies and only keep react-navigation, and it still happens and the docs of react-navigation do not say anything about that. How can I

How to use drawer navigator and tab navigator simultaneously?

一个人想着一个人 提交于 2021-02-17 06:14:05
问题 This is my tab navigator: <Tab.Navigator initialRouteName="Home" backBehavior="initialRoute"> <Tab.Screen name="Science" component={Science} options={{ tabBarLabel: 'Science', tabBarIcon: ({color, size}) => ( <Image source={require('../../assets/images/science-tab.png')} /> ), }} /> <Tab.Screen name="Dashboard" component={Dashboard} /> </Tab.Navigator> This is DrawerNavigator: <Drawer.Navigator initialRouteName="Home"> <Drawer.Screen name="Home" component={HomeScreen} /> <Drawer.Screen name=

undefined is not an object (evaluating 'navigation.navigate'), Cant render properly in react native

余生长醉 提交于 2021-02-11 14:31:03
问题 I have Two files "Browse.js" and "Setting.js" I have render MY complete Browse Screen in "Setting.js" like this function NotificationsScreen({ navigation }) { return ( <Browse /> ); } this is working its rendering But problem is that, when I click on Specific tab Then got this error = undefined is not an object (evaluating 'navigation.navigate') this is my Browse.js import React, { Component } from "react"; import { Dimensions, Image, StyleSheet, ScrollView, TouchableOpacity, View, } from

how to create a drawer using React Native?

假装没事ソ 提交于 2021-02-11 14:25:11
问题 I want to create a drawer that appears only on my homescreen, had tried using React Native side menu but that just hides the drawer behind then tried using createdrawernavigator but I have a bottomtabnavigator inside stacknavigator, and am stuck on how to implement drawer navigator on top of that below is my navigation.js const RootStack = createStackNavigator(); const Tab = createBottomTabNavigator(); const AuthStack = createStackNavigator(); // const Drawer = createDrawerNavigator();

Dynamically navigating between stacks with react-navigation 5

依然范特西╮ 提交于 2021-02-11 14:22:47
问题 I'm trying to dynamically navigate between stacks via a single fetch from a server, which reads a token from the device, and makes a server request to update isUserExists. if isUserExists is false, render AuthStack, otherwise render AppStack. My code: Example for AuthStack.js : import React from "react"; import { createStackNavigator } from "@react-navigation/stack"; import { Auth, Registration, Login, VerifyAuth } from "../../screens/auth"; const Stack = createStackNavigator(); const