react-navigation

React Navigation - How to calling function from another file and use it on headerRight onPress?

巧了我就是萌 提交于 2019-12-11 14:06:33
问题 I wonder there's a way to using headerRight onPress to doing something like calling Alert : I have a function inside MyPet.js with the code : _alert=()=>{ alert('saving') } and in router.js I have a list of all screen I've used to navigating with a piece of code like : export const MyPatientStack = StackNavigator({ MyPatient: { screen: MyPatient, navigationOptions: { tabBarLabel: 'My Patient', tabBarIcon: ({ tintColor, focused }) => <FontAwesome name="wheelchair" size={25} color={tintColor} /

How to Handle Two navigator in react navigation?

妖精的绣舞 提交于 2019-12-11 12:01:53
问题 Hello Guys , I have some issue with React navigation V3 , In my app, I have an Authentication step to Entering to Home Screen and it doesn't have a Drawer Navigation as a default, it will be Stack Navigator Splash => Sign-up => Sign-in => Home And in The Home Screen must Contain a Drawer Navigation And StackNavigation at the same time. I'm Write one file named as a Route.js contain all of my Navigations, But Now createAppContainer just accept on arg like this I think. export default MyApp =

React Native Navigation on Restart

一个人想着一个人 提交于 2019-12-11 07:29:14
问题 I am using the react-native-restart library for restarting the app so I can change the app language in the runtime. After I restart the app I want to change the first StackNavigator screen in the react-navigation library after restarting the app. Navigator class is like this import Screen1 from './Screen1' import Screen2 from './Screen2' import Screen3 from './Screen3' import {StackNavigator} from 'react-navigation'; const Navigator = StackNavigator({ Screen1: { screen: Screen1 }, Screen2: {

Modal window in React Native with react-navigation

烂漫一生 提交于 2019-12-11 07:19:46
问题 I am using react-navigation in React Native and I want, on startup, to determine if the user is logged in, and if he/she is already logged in, I want to open a modal window (full screen). How is this best done? I cannot find anything in the react-navigation docs where a screen is conditionally shown. 回答1: Look, you needs to change the mode from Navigation. const RootStack = StackNavigator( { Main: { screen: MainStack, }, MyModal: { screen: ModalScreen, }, }, { mode: 'modal', headerMode: 'none

implement tabs in the center of the screen

孤人 提交于 2019-12-11 06:57:56
问题 I am new to react native. i have implemented stacknavigator inside drawernavigator. Using this library "react-navigation": "^1.0.0-beta.11", Now i want to implement tabs within the screen at the center. Following image is part of my screen i dont have any idea how can i do this with any library or manually putting views. Any help is appreciated. Thanks 回答1: Well, I've solved that scenario using react-native-swiper Basically you have to wrap all views you want to have inside a Swiper, render

React-redux navigation after calling API

僤鯓⒐⒋嵵緔 提交于 2019-12-11 06:26:47
问题 Below is my reducer code. import * as Helper from '../utils/helper'; import AppNavigator from "../Navigation/navigationStack"; const initialState = { user: "" }; export function pedagogyReducer(state = initialState, action){ switch (action.type) { case 'REGISTER':{ state = { ...state, user: action.newUser, showError: action.showError ? action.showError : false, errorMessage: action.errorMessage ? action.errorMessage: "", } console.log(action.showError); { ////////here I want to redirect to

Unable to use StackNavigator in ReactNative

大城市里の小女人 提交于 2019-12-11 06:24:36
问题 I'm trying to create a simple navigation in the following page: Page1: import React, { Component } from 'react'; import { Text, View, TouchableOpacity, Alert } from 'react-native'; import { StackNavigator } from 'react-navigation'; import { connect } from 'react-redux'; var styles = require('./styles'); class Page1 extends Component { static navigationOptions = { header: null }; componentDidMount() { // <== Edited setTimeout(function() { const { navigate } = this.props.navigation; },4000); }

Is there a proper way to use useNavigation() hook with useEffect() dependencies?

青春壹個敷衍的年華 提交于 2019-12-11 06:03:35
问题 I'm trying to interact with react-navigation using useNavigation() hook in response to a callback I'm registering in useEffect(). The linter is warning me that useEffect() has a missing dependency. If I add the navigation hook as a dependency, the effect continuously runs. I'm trying to avoid this and wondering if there is a correct way other than ignoring the linter error. Providing no dependency array results in the same behavior where the effect continuously fires. This may be an

How to fix undefined is not an object (evaluating 'Component.router.getStateForAction') in React Native

不打扰是莪最后的温柔 提交于 2019-12-11 05:39:10
问题 I am facing some issue to upgrade all libraries of React Native from old to latest. Please help me with the error if you can understand and can suggest me possible solution. Thank You. react-navigation, redux, redux-saga Package.json { "name": "MyApp", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest", "android-bundle": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output

Snapshot test with Jest on nested react-navigation component - Object keys change so Snapshot match fails

▼魔方 西西 提交于 2019-12-11 05:33:35
问题 When I run my jest test on my StackNavigator.test.js it always fails because of generated keys : - Snapshot + Received @@ -79,11 +79,11 @@ fromRoute={null} index={0} navigation={ Object { "_childrenNavigation": Object { - "**id-1542980055400-0**": Object { + "**id-1542980068677-0**": Object { "actions": Object { "dismiss": [Function], "goBack": [Function], "navigate": [Function], "pop": [Function], @@ -109,11 +109,11 @@ "replace": [Function], "reset": [Function], "router": undefined,