react-navigation

createBottomTabNavigator with dynamic tabStyle for different tabs

寵の児 提交于 2020-01-24 20:44:28
问题 According to the Document, I can change activeTintColor and activeBackgroundColor in tabBarOptions . Is there a way to style the tab button with something like activeTabBarStyle ? I want to add a borderTop to the active tab, like this: So I created a function for the defaultNavigationOptions to dynamically assign the tabStyle for different tabs: // ... const BottomNavigator = createBottomTabNavigator({ Users: { screen: UsersStackNavigator, }, Dashboard: { screen: DashboardStackNavigator, },

How to test a button click in React with TypeScript, Jest and Enzyme

若如初见. 提交于 2020-01-24 12:00:09
问题 I'm building a React Native app with TypeScript. I'm doing my component tests using Jest and Enzyme. I'm also using React Navigation I'm struggling to write the unit test for clicking my button. Here is the component's code (just the render function): render() { const { navigation } = this.props; return ( <View style={styles.container}> <Button raised title={strings.painButtonTitle} buttonStyle={styles.painButton} titleStyle={styles.title} onPress={() => navigation.navigate("QuestionsScreen")

React native back button missing icon

落花浮王杯 提交于 2020-01-24 11:33:05
问题 I'm developing a react native module for an existing mobile app, using react-navigation component: import { StackNavigator } from 'react-navigation'; .... const App = StackNavigator({ Main: { screen: Main, navigationOptions: { headerBackTitle: null, } }, Details: { screen: Details, navigationOptions: { headerBackTitle: null, } } }); In Main index I render a simple button that on click do this: render() { const navigation = this.props.navigation; return ( <View> <Button title="Go to details"

React Navigation Preventing Going back to loading screen, reset not working

為{幸葍}努か 提交于 2020-01-21 14:25:56
问题 I have a React Native application which I have implemented. Currently the app opens up on a loading screen which after mounting checks the firebase.auth().onAuthStateChanged(...) feature. The app basically decides whether or not to got to the login screen or to main screen depending on whether or not the user is already authenticated. It is implemented like this: Main Navigator: const MainNavigator = TabNavigator({ auth: { screen: TabNavigator({ login: { screen: LoginScreen }, signup: {

React Native Android Clipping Children

让人想犯罪 __ 提交于 2020-01-17 01:11:11
问题 I am creating a react native app using expo, and I am creating a dropdown in the header. On iOS the dropdown works as desired, and goes 'above' the main content, while on Android it is clipped or goes 'under'. I am not sure if in reality iOS is acting strange, or Android is. The header is a custom headerTitle component, which holds the custom dropdown component (a view, which holds the dropdown items (Views with text and icons) I am looking to get around this issue, and I have tried zIndex

React Native - Accessing drawer navigation outside of AppNavigator

故事扮演 提交于 2020-01-16 09:08:44
问题 App.js <Store> <Navbar /> <AppNavigator ref={navigatorRef => { NavigationService.setTopLevelNavigator(navigatorRef); }} /> </Store> I wanna be able to access props.navigation.openDrawer(); from navbar but I get undefined is not an object (evaluating 'props.navigation.openDrawer') onPress Navbar.js:70:29 etc.. How can I allow NavBar to access the drawer? 回答1: I suppose you are following Navigating without the navigation prop (if you don't then you should in your case). Then in

Custom navigation operation on specific tab button of react-navigation's tab navigator

限于喜欢 提交于 2020-01-16 08:29:13
问题 I wanna open drawer (for example, options menu) from specific button on tab instead of navigating to screen. My current solution was working on react-navigation v2 but as we upgraded from v2 to v3 of react-navigation and v60 of react-native from v57, the solution has stopped working. There is a dummy screen assigned to the menu tab button in tab bar and I am intercepting the navigation operation using tabBarOnPress() . The method opens drawer and returns if it matches the menu button's route

How to handle locked orientation using React Native Stack Navigation

六月ゝ 毕业季﹏ 提交于 2020-01-16 05:24:27
问题 I've an React Native Expo app running on both iOS and Android using Stack Navigation with two views. The first view is locked to portrait screen orientation export class HomeScreen extends Component { componentWillMount() { ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT_UP); } render() {... } } The second view should be available in both portrait and landscape screen orientation: export class DetailScreen extends Component { componentDidMount() { ScreenOrientation

Navigate to specific tab from Drawer Navigator

為{幸葍}努か 提交于 2020-01-15 04:01:13
问题 Is it possible to nest a Tab Navigator inside of a Drawer Navigator and then navigate to a specific tab from the Drawer? Consider this very basic set up: const PrimaryNav = createBottomTabNavigator({ ScreenOne, ScreenTwo }) export const DrawerNavigator = createDrawerNavigator({ Home: { screen: PrimaryNav, drawerLabel: 'Option 1', }, Investment: { screen: PrimaryNav, drawerLabel: 'Option 2', } }) Obviously, this set up will just resolve to the first item in the TabNav regardless of which

Switch Navigator and Tab Navigator Conflict

烂漫一生 提交于 2020-01-14 05:23:09
问题 I have just implemented an Auth stack and having an issue with my TabNavigator - when I click my second "Favourites" tab which is in my tab navigator and referenced the MainNavigator within my switch I get the message There is no route named 'Favourites' in the navigator with the key 'Dashboard. Must be one of: 'Dashboard, Admin' . This was working perfectly fine before I introduced switch navigator and had MainNavigator in my appContainer. Any clues? import React from "react"; import {