react-navigation

How do we call the specific type of action in react-navigation?

主宰稳场 提交于 2019-12-01 13:57:27
How to call action using NavigationAction??? Here if the user doesn't have a token, it goes back to the initial page. I want to reset(initialize) the MainTabNavigator . componentWillReceiveProps(nextProps) { if ( nextProps.token == undefined || _.isNil(nextProps.token) ) { const backAction = NavigationActions.back({ key: null }) nextProps.navigation.dispatch(backAction); Here is MainTabNavigator. I added route to reset everything when 'MyCompleteReset' is triggered. export default TabNavigator({ ........ }); const navigator = MainTabNavigator; const defaultGetStateForAction = navigator.router

How do we call the specific type of action in react-navigation?

余生长醉 提交于 2019-12-01 12:06:41
问题 How to call action using NavigationAction??? Here if the user doesn't have a token, it goes back to the initial page. I want to reset(initialize) the MainTabNavigator . componentWillReceiveProps(nextProps) { if ( nextProps.token == undefined || _.isNil(nextProps.token) ) { const backAction = NavigationActions.back({ key: null }) nextProps.navigation.dispatch(backAction); Here is MainTabNavigator. I added route to reset everything when 'MyCompleteReset' is triggered. export default

How to navigate in mobx store using react navigation?

ⅰ亾dé卋堺 提交于 2019-12-01 11:38:38
问题 I can use this.props.navigation from screen component to navigate. How should I do the similar in mobx store file? Or should I perform navigation in store? I read the Navigating without the navigation prop article, but it seems only works for screen components, right? Someone says use global variable to store a this.props.navigation reference and use it anywhere, but I don't like the idea... 回答1: Yes either: forward the navigation class to the store when calling the method: // add nivagation

React Navigation default background color

坚强是说给别人听的谎言 提交于 2019-12-01 10:16:16
问题 I'm using react-navigation and stack-navigator to manage my screens. Platforms I'm using: Android React Native: 0.47.1 React Navigation: 1.0.0-beta.11 Emulator and Device I have a screen, which acts as a modal form but it is really a full screen. Why is it important the part of "acts as a modal form" ? That's because it is kind of modal menu with some options and WITH A TRANSPARENT BACKGROUND COLOR . This is what I expect: But what I'm getting is this: As you can see, in the second example

Fix Error: The component for route 'Home' must be a React component

ⅰ亾dé卋堺 提交于 2019-12-01 06:45:18
I'm trying to used react-navigation but I can not get it to work when I move each screens' components into multiple files. I always get this error: "The component for route 'Home' must be a React component". This error doesn't happen if I move all of the code into one file, so I'm not sure what the difference is. Here is my App.js: import React from 'react'; import { StackNavigator } from 'react-navigation'; import { AppRegistry, StyleSheet, Text, View, TouchableHighlight } from 'react-native'; import { HomeScreen } from './screens/HomeScreen'; import { JoinScreen from './screens/JoinScreen';

Hide TabNavigators and Header on Scroll

醉酒当歌 提交于 2019-12-01 04:18:52
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.newView}}><Text>Test</Text></View> <View style={{styles.newView}}><Text>Test</Text></View> <View style={

Fix Error: The component for route 'Home' must be a React component

回眸只為那壹抹淺笑 提交于 2019-12-01 01:37:00
问题 I'm trying to used react-navigation but I can not get it to work when I move each screens' components into multiple files. I always get this error: "The component for route 'Home' must be a React component". This error doesn't happen if I move all of the code into one file, so I'm not sure what the difference is. Here is my App.js: import React from 'react'; import { StackNavigator } from 'react-navigation'; import { AppRegistry, StyleSheet, Text, View, TouchableHighlight } from 'react-native

React Navigation check if previous screen exists

被刻印的时光 ゝ 提交于 2019-11-30 23:21:52
I am looking desperately for a possibility to check if a previous screen exists in ReactNavigation. Using this.props.navigation.goBack() returns false if no previous route exists, but I can not use it because if a previous route exists I get redirected. Is there a possibility to check if I opened the app instead of navigated from another screen to the Home screen? Thank you. I am not using Redux. It would make such stuff easier but I would like to avoid using it at the moment. What could be a solution (not sure that it's the best one) would be to spend in the param object the previous screen.

How to Lock drawer for specific page using drawerNavigation [react-navigation][react-native]

巧了我就是萌 提交于 2019-11-30 20:09:43
This is my drawerNavigation : const DashboardStack = StackNavigator({ Dashboard: { screen: Dashboard }, }, { headerMode: 'screen', }); const DetailsformStack = StackNavigator({ Detailsform: { screen: Detailsform }, }, { headerMode: 'none' }); const OtpStack = StackNavigator({ Otp: { screen: Otp, drawer: { lockMode: 'locked-closed' } }, }, { headerMode: 'none' }); const MobilenumberStack = StackNavigator({ Mobilenumber: { screen: Mobilenumber }, }, { headerMode: 'none' }); const DrawerviewStack = StackNavigator({ Drawerview: { screen: Drawerview }, }, { headerMode: 'none' }); const

How to pass params to DrawerNavigator?

时光怂恿深爱的人放手 提交于 2019-11-30 19:34:36
问题 TL D R: I have a Login screen where user logs in and navigates to second screen. There I want to open the menu and have the user name appear as text. How can I pass the user name to the menu? (DrawerNavigator). Some samples of my code below. Router: import MyMenu from './MyMenu'; const MyStack = StackNavigator({ Login: {screen: Login}, Home: {screen: Home} // more screens... }); export const MyDrawer = DrawerNavigator({ Main: { screen: MyStack } }, { contentComponent: MyMenu } ); Home Screen: