react-navigation

React Native NavigationDrawer - How can i launch an alert inside createDrawerNavigation

梦想与她 提交于 2021-02-08 04:09:05
问题 i am trying to trigger a logout (an alert to confirm) from an item click in a navDrawer made with reactnavigation. Do you know an efficient way to do that? This is the code in the DrawerNavigator file: export default createDrawerNavigator({ Home: { screen: Home }, Dashboard: { screen: Dashboard }, Logout: { screen: Logout } } ... And when trying to call the last element (Logout) i know i need to call a class which extends from Component class, but the question like the next code, in this case

Dynamically change header title on react navigation 5.x

对着背影说爱祢 提交于 2021-02-07 18:39:06
问题 I have recently updated my project to react navigation 5.x. In earlier version we used to set header title as follows : static navigationOptions = ({ navigation }) => ({ title: 'find', }); This is not working on React Navigation 5.x. Please Suggest. 回答1: You can do it via 2 methods; 1: Set options to be a variable from your screen and keep your current code: <Stack.Screen name="Label" component={Component} options={Component.navigationOptions} /> // component static navigationOptions = {

Dynamically change header title on react navigation 5.x

扶醉桌前 提交于 2021-02-07 18:38:05
问题 I have recently updated my project to react navigation 5.x. In earlier version we used to set header title as follows : static navigationOptions = ({ navigation }) => ({ title: 'find', }); This is not working on React Navigation 5.x. Please Suggest. 回答1: You can do it via 2 methods; 1: Set options to be a variable from your screen and keep your current code: <Stack.Screen name="Label" component={Component} options={Component.navigationOptions} /> // component static navigationOptions = {

TypeError: No “routes” found in navigation state

可紊 提交于 2021-02-07 12:24:41
问题 I am using createMaterialTopTabNavigator from react-navigation in which i have two separate screens UpdatesStack and ShopsStack and i want to navigate to other screen from these screens so i written like <Toptab navigation={this.props.navigation} /> and it showing me following red screen error. And if i write like <Toptab /> then there is no error but i am not able to navigate. so how can i solve this problem and able to navigate. code class Parenthome extends Component { render() { const {

Hide header on StackNavigator with React Navigation in React Native

三世轮回 提交于 2021-02-07 12:18:55
问题 I have the following: import React from 'react'; import { StyleSheet, Text, View, Button } from 'react-native'; import { StackNavigator } from 'react-navigation'; class HomeScreen extends React.Component { render() { const { navigate } = this.props.navigation; return ( <View> <Text>Hello, Chat App!</Text> <Button onPress={() => navigate('Chat')} title="Chat with Lucy" /> </View> ); } } class ChatScreen extends React.Component { render() { return ( <View> <Text>Chat with Lucy</Text> </View> );

Hide header on StackNavigator with React Navigation in React Native

荒凉一梦 提交于 2021-02-07 12:16:44
问题 I have the following: import React from 'react'; import { StyleSheet, Text, View, Button } from 'react-native'; import { StackNavigator } from 'react-navigation'; class HomeScreen extends React.Component { render() { const { navigate } = this.props.navigation; return ( <View> <Text>Hello, Chat App!</Text> <Button onPress={() => navigate('Chat')} title="Chat with Lucy" /> </View> ); } } class ChatScreen extends React.Component { render() { return ( <View> <Text>Chat with Lucy</Text> </View> );

Hide header on StackNavigator with React Navigation in React Native

别来无恙 提交于 2021-02-07 12:16:35
问题 I have the following: import React from 'react'; import { StyleSheet, Text, View, Button } from 'react-native'; import { StackNavigator } from 'react-navigation'; class HomeScreen extends React.Component { render() { const { navigate } = this.props.navigation; return ( <View> <Text>Hello, Chat App!</Text> <Button onPress={() => navigate('Chat')} title="Chat with Lucy" /> </View> ); } } class ChatScreen extends React.Component { render() { return ( <View> <Text>Chat with Lucy</Text> </View> );

React Native StackNavigator initialRouteName

谁都会走 提交于 2021-02-07 05:14:40
问题 In React Native Navigation library 'react-navigation' How could I set StackNavigator initialRouteName by AsyncStorage? function getInitialScreen() { AsyncStorage.getItem('initialScreen') .then(screenName => { return (screenName) ? screenName : 'Login'; }) .catch(err => {}); } const Navigator = StackNavigator({ Splash: { screen: Splash }, Login: { screen: Login }, WebPage: { screen: WebPage } }, { initialRouteName: getInitialScreen() }); 回答1: Changing InitialRouteName with multiple Route

React Native StackNavigator initialRouteName

一世执手 提交于 2021-02-07 05:14:09
问题 In React Native Navigation library 'react-navigation' How could I set StackNavigator initialRouteName by AsyncStorage? function getInitialScreen() { AsyncStorage.getItem('initialScreen') .then(screenName => { return (screenName) ? screenName : 'Login'; }) .catch(err => {}); } const Navigator = StackNavigator({ Splash: { screen: Splash }, Login: { screen: Login }, WebPage: { screen: WebPage } }, { initialRouteName: getInitialScreen() }); 回答1: Changing InitialRouteName with multiple Route

React Native StackNavigator initialRouteName

∥☆過路亽.° 提交于 2021-02-07 05:13:04
问题 In React Native Navigation library 'react-navigation' How could I set StackNavigator initialRouteName by AsyncStorage? function getInitialScreen() { AsyncStorage.getItem('initialScreen') .then(screenName => { return (screenName) ? screenName : 'Login'; }) .catch(err => {}); } const Navigator = StackNavigator({ Splash: { screen: Splash }, Login: { screen: Login }, WebPage: { screen: WebPage } }, { initialRouteName: getInitialScreen() }); 回答1: Changing InitialRouteName with multiple Route