navigation.js
import React,{ Component} from 'react'
import { createStackNavigator,createAppContainer } from 'react-navigation'
import Login from './screens/login'
import SplashScreen from './screens/splashScreen'
// export const Nav = createStackNavigator({
// splashScreen: { screen: SplashScreen },
// loginScreen: { screen:Login },
// },{ initialRouteName: 'splashScreen' })
// export default createAppContainer(Nav);
const Nav = createStackNavigator({
loginScreen: { screen: Login },
splashScreen: {screen: SplashScreen},
{
initialRouteName: 'splashScreen',
}
})
export default createAppContainer(Nav);
splashscreen.js
import React, { Component } from "react";
import { Image, StyleSheet, Text, TouchableOpacity, View } from "react-native";
import { appContainer } from '../styleSheet'
import { Nav } from '../navigations'
import { createStackNavigator,createAppContainer } from 'react-navigation'
class SplashScreen extends Component {
componentWillMount(){
setTimeout(() => {
// alert('I will redirect')
this.props.navigation.navigate("loginScreen");
}, 3000);
}
render() {
return (
<View style={appContainer.AppContainer}>
<Text style={appContainer.splashSC}> Who Around Me </Text>
</View>
)
}
}
export default SplashScreen
login.js
import React, { Component } from "react";
import { Image, StyleSheet, Text, TouchableOpacity, View } from "react-native";
import { appContainer,buttons } from '../styleSheet'
class Login extends Component {
render() {
return (
<View style={appContainer.AppContainer}>
<Text style={buttons.loginBtnText}>
Login with Sim
</Text>
</View>
)
}
}
export default Login
App.js
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
* @lint-ignore-every XPLATJSCOPYRIGHT1
*/
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import SplashScreen from './screens/splashScreen'
import { createStackNavigator,createAppContainer } from 'react-navigation'
import Login from './screens/login'
import { Nav } from './navigations'
const App = () => (
<Nav />
);
export default App;
index.android.js
import React, { Component } from "react";
import { AppRegistry } from "react-native";
import { createStackNavigator,createAppContainer } from 'react-navigation'
import App from "./src/App";
AppRegistry.registerComponent("WhoAroundMe", () => App);
this.props.navigation.navigate ("loginScreen"); выдает ошибку
this.props.navigation.navigate undefined
Не удалось решить, выполнив много Google.
Любая помощь приветствуется.
Спасибо