1

I installed react-navigation and all its dependencies step by step based on its documentation. I've created two components in a single file namedroot.js this is the code:

import React from 'react';
import {
    StyleSheet,
    View,
    Text,
    Button,


} from 'react-native';


import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';

This is the first competent:

const Homescreen = () => {
    return (

        <View style={styles.container}>

            <Text>Home screen</Text>
            <Button
                title='go to next page'


            ></Button>

        </View>


    )}

Second one:

const Loginscreen = () => {
    return (

        <View style={styles.container}>

            <Text>Login screen</Text>
            <Button
                title='go back'


            ></Button>

        </View>


    )}

This the navigation code:

const AppNavigator = createStackNavigator({

    Home: { screen: Homescreen },
    Login: { screen: Loginscreen }

},
    {
        initialRouteName: 'Home'

    }


);

export default createAppContainer(AppNavigator);

Then i imported AppNavigator into App.js file like this:

import AppNavigator from './src/root';

const App=() =>  {


  return (

    <View style={styles.container} >


< AppNavigator/>

    </View>



  )
};

react native version is: "0.61.5".

react-navigation version is: "^4.1.1".

And all dependencies have been installed.

I am getting following error, Which part did i make mistake?

enter image description here

1 Answer 1

4

It's possible the install failed for react-navigation-stack. Try installing it again and if you are using npm or yarn as your package manage, look for confirmation in the file package.json.

npm install react-navigation-stack
Sign up to request clarification or add additional context in comments.

1 Comment

You saved my time, I really appreciate it, Issue was solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.