react-navigation

How to add a custom component to createMaterialTopTabNavigator tab bar

拜拜、爱过 提交于 2019-12-04 11:22:48
I am using createMaterialTopTabNavigator from react-navigation and trying to customize the tab bar by adding some components on top of it. As you can see in its guide here: https://reactnavigation.org/docs/en/material-top-tab-navigator.html#docsNav there is an option called tabBarComponent that can be passed to create your own tab bar. However, it completely overrides the tab bar which is not what I want. I'd like to add a custom component at the top of the tab bar and then have the default tabs with their labels underneath. Can anyone show me an example of how to add a component to the tab

Remove screen from stack navigator

允我心安 提交于 2019-12-04 06:43:09
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"; import { Root } from "native-base"; import { StackNavigator, DrawerNavigator} from "react-navigation";

A Custom Tab bar with two images in each tab using react navigation?

柔情痞子 提交于 2019-12-04 05:49:32
I am creating an app using React Native for ios. Instead of having an active tintColor I want to have two little triangles (another image/icon) which appears when you are on the selected tab. It is important that the center y axis of the triangles is = to the y axis of the bottom of the tabbar image and that the tab icon is in the center of the triangles as seen below. At the moment I have the tab bar, the icons and navigation working - I just don't know how to make the triangles appear: ICON TABS import React, {Component} from 'react'; import { Image, TouchableOpacity, View } from 'react

Conditional React Navigation header button

╄→гoц情女王★ 提交于 2019-12-04 05:25:38
问题 I am trying to make a button appear in headerRight of the header bar in a React Navigation screen, but I cant seem to get it to work. I want the start button (what is in headerRight ) to show when props.players.length > 1 . Can anyone point me in the right direction? 回答1: You can use the same mechanics describe here for title: https://reactnavigation.org/docs/en/headers.html#setting-the-header-title Set a navigation params and use it on your navigationOptions. In your case: state = { players:

How to get drawer over the header in react navigation?

假装没事ソ 提交于 2019-12-04 04:26:28
I am using react navigation. I want to show drawer over the header of the screen. Currently my header is not hiding below drawer when I open the drawer. import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; import { createStackNavigator, createDrawerNavigator } from 'react-navigation'; import CategoryScreen from './CategoryScreen'; import ProductsScreen from './ProductsScreen'; import CartScreen from './CartScreen'; const drawerScreens = createDrawerNavigator ({ Category: CategoryScreen, Products: ProductsScreen, },{ initialRouteName: 'Category' } ) export default

Testing component that uses react-navigation with Jest

£可爱£侵袭症+ 提交于 2019-12-04 00:36:46
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...</Text> </View> ); }; Loading.propTypes = { rehydrated: PropTypes.bool.isRequired, navigation:

how to display headers in react navigation with TabNavigation

旧街凉风 提交于 2019-12-03 22:12:44
I noticed that views in StackNavigation show the header title but if I set those same screens in a TabNavigation it doesn't show a header. It only shows a header if I wrap a StackNavigation either around each tab, or wrap the TabNavigation nested inside a StackNavigation. Why don't screens in TabNavigation show a header - is that expected behavior? If so, is it better to have a StackNavigation in each tab, or one big StackNavigation around the TabNavigation? // tabs navigation doesn't show a header title in each screen const TabsNavigator = TabNavigator({ Home: { screen:HomeScreen, }, Profile:

React native router flux: TypeError: undefined is not a function (evaluating 'addListener')

帅比萌擦擦* 提交于 2019-12-03 20:13:31
Im working on a react native app using this principal dependencies: react native react native router flux react thunk expo I was working using this package.json: "dependencies": { "expo": "23.0.4", "humps": "^2.0.0", "install": "^0.10.1", "lodash": "^4.17.4", "native-base": "^2.3.5", "react": "16.0.0", "react-native": "0.50.4", "react-native-extend-indicator": "^0.1.2", "react-native-keyboard-aware-scroll-view": "^0.4.2", "react-native-maps": "^0.19.0", "react-native-maps-directions": "^1.3.0", "react-native-modal-datetime-picker": "^4.13.0", "react-native-qrcode": "^0.2.6", "react-native

React Navigation: How to update navigation title for parent, when value comes from redux and gets updated in child?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 16:40:44
问题 I'm using react-navigation and have a StackNavigator with a ParentScreen and a ChildScreen . Both screens have the same navigation bar with a dynamic value from redux. Implemented like described in Issue #313 This works as expected. When I'm in DetailScreen and I update the value for the count variable, it also updates the value in the navigation bar. Problem is, if I go back to the parent scene, there is still the old value in the navigation bar. It doesn't update to the current value in

How to stop the Android Hardware Back Button from functioning in react-navigation for react-native?

荒凉一梦 提交于 2019-12-03 16:03:56
I am developing a trivia game, I am using react-navigation to handle navigation, I have 3 components, (newGame, Questions, Results ) I don't want the user to go back to the questions from the results page if the no. of questions has been exhausted, however, pressing the back button ( Android Hardware ) is taking him back to the questions. I then tried to handle the hardware back button like so: componentWillMount() { this.props.gameState(true); BackHandler.addEventListener('hardwareBackPress', () => { if (this.props.gamePlaying) { // Currently set to true. I will set it to false again on