react-navigation

Could not navigate to another screen when using token in React Native

早过忘川 提交于 2019-12-08 11:09:33
问题 I'm currently developing an app using react native, right now my issue is that i couldn't navigate to main screen after login. Below is my code. This is App.js ( EDITED ) import React from 'react'; import { Loading } from './components/common/'; import TabNavigator from './screens/TabNavigator'; import AuthNavigator from './screens/AuthNavigator'; import MainNavigator from './screens/MainNavigator'; import deviceStorage from './services/deviceStorage.js'; import { View, StyleSheet } from

Align the Header in center

試著忘記壹切 提交于 2019-12-08 10:58:22
问题 react-navigation: 1.0.0-beta.11 react: 16.0.0-alpha.12 react-native: 0.47.1 I'm following the ReactNavigation tutorial to render the Header from a passed prop to the screen. class ChatScreen extends React.Component { static navigationOptions = ({ navigation }) => ({ title: `Chat with ${navigation.state.params.user}`, // <- Talking bout this }); render() { const { params } = this.props.navigation.state; return ( <View> <Text>Chat with {params.user}</Text> </View> ); } } I want the title in

How Redirect to Login if page is protected and the user is not signed in?

时间秒杀一切 提交于 2019-12-08 09:33:21
问题 In my App I have some public screens that are accessible even if the user is not logged in, and some screens are protected (you must be logged in to access them). My solution to the problem is to check the component willFocus Listener and if not logged in, the user should be redirected to the loginPage. export async function ProtectRoute(navigation){ //if page will enter and the user is not authenticated return to login navigation.addListener( 'willFocus', async () => { let token = await

React Native 0.56 + Enzyme + Jest + React Navigation: Enzyme crashes because of import statement

三世轮回 提交于 2019-12-08 06:24:20
问题 TL;DR: My tests crash, because of the following error linked to React Navigation: /path-to-app/react-native/myApp/node_modules/react-navigation/src/views/withNavigation.js:1 ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import React from 'react'; ^^^^^^ SyntaxError: Unexpected token import 127 | } 128 | > 129 | export default withNavigation( | ^ 130 | connect( 131 | null, 132 | { loginSuccess } at ScriptTransformer._transformAndBuildScript (node

React Native: Passing props to nested navigation

社会主义新天地 提交于 2019-12-08 05:59:37
问题 I'm using the slick React Navigation and following the nested navigation recipe here, but i don't know how to pass 'this' to my navigation. Sorry for my ignorance. Here is my general structure outline: class MyApp extends Component { render() { return ( <StackNavigation screenProps={this.state} /> ) } } const MainScreenNavigator = TabNavigator( { Awesome: { screen: Awesome } // How do I pass this.state? } ) const routesConfig = { Home: { screen: MainScreenNavigator }, Profile: { screen:

Cannot read property 'navigate' of undefined in react-navigation

对着背影说爱祢 提交于 2019-12-08 05:11:33
问题 I have used import { StackNavigator } from 'react-navigation'; in my Router.js import { StackNavigator } from 'react-navigation'; import LoginForm from './components/LoginForm'; import EmployeeList from './components/EmployeeList'; import EmployeeCreate from './components/EmployeeCreate'; const RouterComponent = StackNavigator( { LoginForm: { screen: LoginForm, navigationOptions: { title: 'Please Login' } }, EmployeeList: { screen: EmployeeList, }, EmployeeCreate: { screen: EmployeeCreate,

navigation between component in react native

点点圈 提交于 2019-12-08 03:42:02
问题 I need to navigate between two view in React Native. But the problem is my component where the button to navigate is on an other component. I use the react-navigation. Let me show you : I have my component MainPage here class MainPage extends Component { render() { return <View style={styles.container}> <ComponentWithButton /> </View> } } So in my component ComponentWithButton : class ComponentWithButton extends Component { goToComponent(){ this.props.navigation.push('Next') } render() {

React Navigation Drawer: Dynamically routes and navigation items?

老子叫甜甜 提交于 2019-12-08 03:29:47
问题 Right now I am facing a problem.. Before my application gets mounted, I am fetching categories from an API. Now I want to have a dynamic app which always contains the newest data. I want to have the different categories always as a separated screen. The functions I need for every category screen is always the same. So, I have build myself a screen template. However, I have to fetch the different categories from the API and then import my template screen as many times as I have fetched

Why is my this.props.navigation.setParams not working?

故事扮演 提交于 2019-12-08 02:51:21
问题 I'm setting my integer array on selectedStyleIds. Why is my this.props.navigaion.setParams not working? _setSelectedStyleIds = (selectedStyleIds) => { const action = NavigationActions.setParams({ params: {selectedStyleIds}, key: 'id-1509842157447-6' <- got this from console }); this.props.navigation.dispatch(action); this.props.navigation.setParams({styleIds:selectedStyleIds}); this.setState({selectedStyleIds}); } onCheck = ({selectedStyleIds}) => { console.log('onCheck'); console.log

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

故事扮演 提交于 2019-12-07 23:59:34
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": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest" },