react-navigation

How to swipe horizontally inside stackNavigator screens?

断了今生、忘了曾经 提交于 2020-01-03 17:21:11
问题 I'm trying to create a swipe navigation between different screens from a same StackNavigator when i set swipeEnabled:true in navigationOptions , my app rather navigate between different Tabs. I'd rather want to navigate inside a same stack from Screen A to Screen B for example. How can i do this trick ? 回答1: I had the same use case. I wanted a swipaeable <StackNavigator> . The solution I was able to find was to simulate a <StackNavigator> using a <TabNavigator> , or more specifically, using

Error: null is not an object (evaluating 'C.State') <unknown> index.android.bundle

↘锁芯ラ 提交于 2020-01-03 02:59:10
问题 I am new to React-Native. I was integrating my existing Android native app with react native app. The react native part after running app is showing this error: null is not an object (evaluating 'C.State') unknown index.android.bundle Here is the screenshot of the error: Screenshot of error message I know that this error message comes every time I use react-navigation and react-native-gesture-handler . Here is the code for package.json file: { "name": "Demo", "version": "0.0.1", "private":

How to change back button route in react navigation

☆樱花仙子☆ 提交于 2020-01-02 07:02:13
问题 i am using react-navigation (stack-navigation). i want to change my header back button icon route. Home BookTicket MyBookings these are the screens i have in my project.Now when i click header back button in MyBookings screen it should route to Home Screen. 回答1: There must be back button in default if your stackNavigator stack is properly configured. But if you would like to replace the default button just add headerLeft and pass your custom component Screen Navigation Options in the page you

How to use react-navigation's withNavigation in typescript?

主宰稳场 提交于 2020-01-02 03:51:07
问题 I'm trying to use react-native, react-navigation and typescript together to create an app. There are only two screens( HomeScreen and ConfigScreen ) and one component( GoToConfigButton ) in total, as follows. HomeScreen import React from "react"; import { NavigationScreenProps } from "react-navigation"; import { Text, View } from "react-native"; import GoToConfigButton from "./GoToConfigButton"; export class HomeScreen extends React.Component<NavigationScreenProps> { render() { return ( <View

How to reset the state of a StackNavigator nested in a DrawerNavigatior?

試著忘記壹切 提交于 2020-01-02 03:34:06
问题 I am building an app whose navigation is based on a DrawerNavigator from the react-navigation library. This navigator has 3 tabs: 2 regular tabs 1 StackNavigator named "Search" The StackNavigator consists of one screen that lets the user search for an item, and a second screen where the user sees the search results. I do not want the search results page to be a tab of a DrawerNavigator, this is why I implemented this structure. The problem is: if the user has already performed a search, when

React navigation didfocus event listener works differently between class component and functional component

喜夏-厌秋 提交于 2020-01-02 02:51:10
问题 When I transition to this screen, it will do some API calls to fetch the latest data. But it seems not trigger the didFocus event to fire the api calls when I transition from another navigation stack with hooks version while it works well with class version. How do I make hooks version have the same behavior as class version? What's the difference between this two version? class component version class someScreen extends Component { componentDidMount() { const { navigation, } = this.props;

How to mock React Navigation's navigation prop for unit tests with TypeScript in React Native?

吃可爱长大的小学妹 提交于 2020-01-01 08:03:47
问题 I'm building a React Native app with TypeScript. For my navigation I use React Navigation and for my unit testing I use Jest and Enzyme. Here is the (stripped down) code for one of my screen (LoadingScreen.tsx): import styles from "./styles"; import React, { Component } from "react"; import { Text, View } from "react-native"; import { NavigationScreenProps } from "react-navigation"; // Is this correct? export class LoadingScreen extends Component<NavigationScreenProps> { // Or should I've

How to mock React Navigation's navigation prop for unit tests with TypeScript in React Native?

天大地大妈咪最大 提交于 2020-01-01 08:03:35
问题 I'm building a React Native app with TypeScript. For my navigation I use React Navigation and for my unit testing I use Jest and Enzyme. Here is the (stripped down) code for one of my screen (LoadingScreen.tsx): import styles from "./styles"; import React, { Component } from "react"; import { Text, View } from "react-native"; import { NavigationScreenProps } from "react-navigation"; // Is this correct? export class LoadingScreen extends Component<NavigationScreenProps> { // Or should I've

React Native - how to scroll a ScrollView to a given location after navigation from another screen

ぃ、小莉子 提交于 2020-01-01 05:28:06
问题 Is it possible to tell a ScrollView to scroll to a specific position when we just navigated to the current screen via StackNavigator? I have two screens; Menu and Items. The Menu is a list of Buttons, one for each item. The Items screen contain a Carousel built using ScrollView with the picture and detailed description of each Item. When I click on a button in the Menu screen, I want to navigate to the Items screen, and automatically scroll to the Item that the button represent. I read that

TabsNavigator inside StackNavigator

妖精的绣舞 提交于 2020-01-01 04:59:07
问题 I'm using React-Navigation and I have a StackNavigator, this is the app.js with the Stack + Tabs Navigator: import React from 'react'; import { AppRegistry } from 'react-native'; import { StackNavigator, TabNavigator } from 'react-navigation'; import LoginScreen from './app/screens/LoginScreen'; import RegisterScreen from './app/screens/RegisterScreen'; import HomeScreen from './app/screens/HomeScreen'; import FriendsScreen from './app/screens/FriendsScreen'; const Stylelist = StackNavigator(