react-navigation

React Navigation on tab change

我的未来我决定 提交于 2019-12-21 04:21:16
问题 Without using Redux, how do I detect a tab change with a react navigation tab navigator? I know I need to somehow use onNavigationStateChange but I can't figure out how to update the current view. export default () => <MyTabNav ref={(ref) => { this.nav = ref; }} onNavigationStateChange={(prevState, currentState) => { //call function on current view }} />; 回答1: export default () => <MyTabNav ref={(ref) => { this.nav = ref; }} onNavigationStateChange={(prevState, currentState) => { const

React Navigation on tab change

∥☆過路亽.° 提交于 2019-12-21 04:21:05
问题 Without using Redux, how do I detect a tab change with a react navigation tab navigator? I know I need to somehow use onNavigationStateChange but I can't figure out how to update the current view. export default () => <MyTabNav ref={(ref) => { this.nav = ref; }} onNavigationStateChange={(prevState, currentState) => { //call function on current view }} />; 回答1: export default () => <MyTabNav ref={(ref) => { this.nav = ref; }} onNavigationStateChange={(prevState, currentState) => { const

React Navigation 'navigation' is missing in props validation

∥☆過路亽.° 提交于 2019-12-21 03:42:57
问题 React Navigation's introduction page suggests the use of the following destructuring assignment: const { navigate } = this.props.navigation; However, when I implemented React Navigation in my App, ESLint is complaining about this line describing these both errors: 'navigation' is missing in props validation (react/prop-types) 'navigation.navigation' is missing in props validation (react/prop-types) Even though the app seems to be working as intended, how would it be possible to remove these

React Navigation - How to switch Tab Navigation to handle Login Screen?

此生再无相见时 提交于 2019-12-20 04:56:05
问题 I want to know if it's possible to handle login screen after the button login pressed, I have a router.js: export const TabLoged= TabNavigator({ Home: { screen: HomeStack, }, MyPatient:{ screen: MyPatientStack }, MyAccount: { screen: MyAccount, } }); export const Tab = TabNavigator({ Home: { screen: HomeStack, }, Login: { screen: LoginStack, } }); export const Root = StackNavigator({ Tab: { screen: Tab, } },{headerMode:'none'}) In export const Root I want to change the code looks like :

Navigate to root screen from nested stack navigator

寵の児 提交于 2019-12-20 03:39:09
问题 i am new to react and trying to learn it by myself , i am facing problem in navigating user back to root screen from nested stck navigator screen . Here is some of my classes :- index.android.js :- import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, StatusBar, View } from 'react-native'; import {LoginStack} from './login/loginregisterrouter'; import {StackNavigator } from 'react-navigation'; class reactNavigationSample extends Component { render(){ return (

React Native - Nothing was returned from render

本小妞迷上赌 提交于 2019-12-20 01:44:33
问题 My application is stored in /src/index.js but i also have a /App.js and a /index.js. I don't know the difference between these and i think thats the reason im getting this error. /index.js import { AppRegistry } from 'react-native'; import App from './App'; AppRegistry.registerComponent('client', () => App); /App.js import App from './src/index'; export default App; /src/index.js import React from 'react'; import { AppRegistry } from 'react-native'; import { Provider, connect } from 'react

BackHandler does not go back more than 1 screen

≡放荡痞女 提交于 2019-12-19 07:23:05
问题 I have this code on each of my screens. Pressing the android back button goes back 1 screen. Pressing android back button again does not do anything. Expected result would be to keep going back as long as there are more screens in the stack. What's missing? componentWillMount() { BackHandler.addEventListener('hardwareBackPress', () => { this.props.navigation.goBack(); return true; }); } componentWillUnmount() { BackHandler.removeEventListener('hardwareBackPress') } 回答1: After some trial and

Hide TabNavigators and Header on Scroll

点点圈 提交于 2019-12-19 06:16:08
问题 I want to hide the Header and the TabNavigator tabs onScroll. How do I do that? I want to hide them onScroll and show them on ScrollUp. My code: import React, { Component } from 'react'; import { View, Text, ScrollView, StyleSheet, TouchableOpacity} from 'react-native'; class ScrollTest extends Component { render(){ const { params } = this.props.navigation.state; return( <View style={styles.container}> <ScrollView> <View style={{styles.newView}}><Text>Test</Text></View> <View style={{styles

Hide TabNavigators and Header on Scroll

杀马特。学长 韩版系。学妹 提交于 2019-12-19 06:14:59
问题 I want to hide the Header and the TabNavigator tabs onScroll. How do I do that? I want to hide them onScroll and show them on ScrollUp. My code: import React, { Component } from 'react'; import { View, Text, ScrollView, StyleSheet, TouchableOpacity} from 'react-native'; class ScrollTest extends Component { render(){ const { params } = this.props.navigation.state; return( <View style={styles.container}> <ScrollView> <View style={{styles.newView}}><Text>Test</Text></View> <View style={{styles

React Native: React Navigation StackNavigator not working. Getting error: “undefined is not an object (evaluating 'this.props.navigation.navigate')”

微笑、不失礼 提交于 2019-12-19 04:50:12
问题 I am trying to use React Navigation and StackNavigator to navigate around my app. I have a button with onPress={() => navigate('DetailsScreen') , and I was hoping that would take me to the DetailsScreen , but I'm getting the following error: E ReactNativeJS: undefined is not an object (evaluating 'this.props.navigation.navigate') What do I need to add in order to get this working? See my code here: https://gist.github.com/chapeljuice/bef4b0a4dedef2994c81f3634b81aa43 回答1: You component is not