如何访问DrawerNavigation路由以在其他组件React-native中使用?

时间:2018-06-19 09:23:16

标签: react-native navigation react-native-router-flux

我正在尝试访问drawernavigator路由以访问ComponentDidMount函数中的其他组件。

我应该通知你,我还没有制作任何路线文件。

我在启动画面上的5秒后收到错误=> undefined不是一个函数(评估' _reactNativeRouterFlux.Actions.HomeScreen()')

我现在该怎么办,请帮忙......

App.js

import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, Hidden, Image } from 'react-native';
import { StackNavigator } from 'react-navigation';
import { DrawerNavigator } from 'react-navigation';
import Settings from './components/Settings';
import Home from './components/Home';
import Register from './components/Register';
import User from './components/User';
import Single from './components/Single';
import Splash from './components/Splash';
import { Router, Scene } from 'react-native-router-flux'

const AppNavigator = DrawerNavigator({
  SplashScreen: {screen: Splash, navigationOptions: { drawerLabel: ()=>null, }},
  HomeScreen: { screen: Home, navigationOptions:{ drawerIcon: ()=> (
        <Image
        source={require('./src/home.png')}
        style={{width: 30, height: 30, borderRadius: 15}}
      />
    )}},
  SettingScreen: { screen: Settings, navigationOptions:{ drawerIcon: ()=> (
        <Image
        source={require('./src/Settings-icon.png')}
        style={{width: 30, height: 30, borderRadius: 15}}
      />
    )}},
  RegisterScreen: { screen: Register, navigationOptions:{ drawerIcon: ()=> (
        <Image
        source={require('./src/registericonpatrol.png')}
        style={{width: 30, height: 30, borderRadius: 15}}
      />
    )}},
  UserScreen: { screen: User, navigationOptions:{ drawerIcon: ()=> (
        <Image
        source={require('./src/users-17.png')}
        style={{width: 30, height: 30, borderRadius: 15}}
      />
    )}},
  SingleScreen: {screen: Single, navigationOptions: { drawerLabel: ()=>null, }},
});


export default class App extends Component {
  render() {
    return <AppNavigator />;
  }
}

Splash.js

import React, { Component } from 'react';
import { View, Text, StyleSheet, Image } from 'react-native';
import Home from './Home';
import { Router, Scene } from 'react-native-router-flux';
import { Actions } from 'react-native-router-flux';
import App from '../App';

class Splash extends Component {
  constructor(props){
    super(props)
      this.state = {
    }
  }

   componentDidMount(){
      setTimeout(()=>{ Actions.HomeScreen() }, 5000);
   }

  render() {
    return (
      <View>
        <Image
        source={require('../src/logos.jpg')}
        />
      </View>
    )
  }
}

export default Splash

文件夹结构为enter image description here

0 个答案:

没有答案