react-navigation

Dynamically hide/show header in react-native

末鹿安然 提交于 2019-12-06 03:20:27
I am using react-navigation for routing purpose. I want to dynamically hide or show header on one component. Any way to do it? I change headerLeft dynamically like this but can not find any way to do it for entire header. static navigationOptions = ({ navigation }) => ({ headerRight: navigation.state.params ? navigation.state.params.headerRight : null }); this.props.navigation.setParams({ headerRight: ( <View> <TouchableOpacity onPress={() => blaa} > <Text>Start</Text> </TouchableOpacity> </View> ) }); I want something like this - hide/show header based on state: this.props.navigation

React Native - React Navigation slow transitions when nesting navigators

纵饮孤独 提交于 2019-12-06 02:42:11
I am building a cross-platform native application using react-native and using react-navigation for navigating to and from screens and managing navigation state using redux. The problem arises when I am nesting my navigators. For example, I am using Stack Navigator as the default navigator for my app. export const DefaultNavigate = new StackNavigator( { Login: { screen: LoginScreen, }, Home: { screen: AppDrawerNavigate, }, AppTabNav: { screen: AppTabNavigator, }, } ); where my first screen is loginscreen and home screen is a drawer navigator. const AppDrawerNavigate = new DrawerNavigator( {

react-navigation: How to change tabBar color based on current tab

会有一股神秘感。 提交于 2019-12-06 01:46:01
问题 I'm getting started with react-navigation. How do I change the tabBar background color when I change tab? Here is some pseudo-code showing what I'm hoping for: _backgroundColor = function() { switch (this.routeName) { case 'tabHome': return { backgroundColor: '#002663' }; case 'tabRewards': return { backgroundColor: '#3F9C35' }; default: return { backgroundColor: 'white' } } } // Tabs setup export const TabStack = TabNavigator({ tabHome: { screen: HomeStack, }, tabRewards: { screen:

Dynamically change drawerPosition config of DrawerNavigator in react-navigation

北战南征 提交于 2019-12-06 00:33:58
I have a DrawerNavigator config for my main routes const App = DrawerNavigator(DrawerRoutes, { initialRouteName: 'Main', contentComponent: ({ navigation }) => <DrawerMenu navigation={navigation} routes={DrawerRoutes} />, mode: Platform.OS === 'ios' ? 'modal' : 'card', drawerWidth: Dimensions.get('window').width - (Platform.OS === 'android' ? 56 : 64), drawerPosition: 'left', }) I want to change the drawerPosition property depending on the current language of the application. I have already tried to connect to redux with no success because it throws an error for invalid React element. How can I

Unable to resolve 'react-navigation'

≡放荡痞女 提交于 2019-12-05 22:59:37
问题 Am trying out react-native and get below error, when I install and try to use react-navigation (import {StackNavigator} from 'react-navigation';). Error I use the following command to install "react-navigation" : npm install --save react-navigation On running above command I get 'react-navigation' folder under node_modules folder, with just a single file ( package.json ). Below is the content of the file: { "_args": [ [ { "raw": "react-navigation@0.0.0", "scope": null, "escapedName": "react

Remove screen from stack navigator

余生颓废 提交于 2019-12-05 22:01:48
问题 I’ve observed Back button logic works seeing the sequence of screens in the stack. I’ve a Drawer navigator placed inside stack navigator. On top of the stack I’ve Splash screen. On Dashboard when I press back button it takes me to splash screen. How can I remove splash screen from stack after entering in the app, So when I press back button Dashboard it will EXIT the app instead of taking to SPLASH SCREEN. /* @flow */ import React from "react"; import { Platform, Text } from "react-native";

react-navigation dynamic header doesn't work?

让人想犯罪 __ 提交于 2019-12-05 21:44:48
I followed exactly the tutorial https://reactnavigation.org/docs/intro/ But the header does not show up. Here is the code and the result import Expo from 'expo'; import React from 'react'; import { StyleSheet, Text, View, Button } from 'react-native'; import {StackNavigator} from 'react-navigation'; class HomeScreen extends React.Component { static navigationOptions = { title: 'Welcome', } render() { const {navigate} = this.props.navigation; return ( <View style={styles.container}> <Text>Open up main.js to start working on your app!</Text> <Button onPress={()=>navigate('Chat',{user:'Lucy'})}

Testing component that uses react-navigation with Jest

倾然丶 夕夏残阳落幕 提交于 2019-12-05 11:23:54
问题 I'm working on a React Native application that also use Redux and I want to write tests with Jest. I'm not able to mock the "navigation" prop that is added by react-navigation. Here is my component: import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import { Text, View } from 'react-native'; const Loading = (props) => { if (props.rehydrated === true) { const { navigate } = props.navigation; navigate('Main'); } return ( <View> <Text>Loading...

React Native error message: Trying to add a root view with an explicit id already set

a 夏天 提交于 2019-12-05 10:14:04
问题 I am currently developing an application with React Native. The basis was Ignite. At the moment, very often when I start the application, I get an error message that I do not understand. Maybe someone can tell me about what it says or how to fix the problem. Trying to add a root view with an explicit id already set. React Native uses the id field to track react tags and will overwrite this field. If that is fine, explicitly overwrite the id field to View.NO_ID before calling addRootView.

undefined is not an object (evaluating 'RootComponent.prototype')

本小妞迷上赌 提交于 2019-12-05 10:11:59
---------index.js-------- import { AppRegistry } from 'react-native'; import Navigate from './Navigate'; AppRegistry.registerComponent('form1', () => Navigate); ----Navigate.js----- import React from 'react'; import { StackNavigator, DrawerNavigator } from 'react-navigation'; import TabsList from './TabsList'; export const StackTab1 = StackNavigator({ TabList: { screen: TabsList}, }); export const Navigate = DrawerNavigator( { Tab1: { screen : StackTab1 }, Tab2: { screen : StackTab1 }, Tab3: { screen : StackTab1 } }); Whenever I try to run my android simulator, I'm getting that error. All