Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

455
Views
Can't find Variable: NavigationContainer

I've been having a problem with NavigationContainer from react-navigation/native. I keep getting an error saying:

ReferenceError: Can't find variable: NavigationContainer

I have import { NavigationContainer } from '@react-navigation/native'; imported at the top but I still get the same error. I checked the package.json and it's installed. I have also uninstalled node_modules twice and I still have the same problem.

"dependencies": {
    "@react-native-community/masked-view": "^0.1.11",
    "@react-navigation/native": "^5.9.8",
    "@react-navigation/stack": "^5.3.5",

Here is my app.js code :

import React from 'react';
import { Text, View } from 'react-native';
import { createStackNavigator } from '@react-navigation/stack';
import Screen from './app/components/Screen';
import { NavigationContainer } from '@react-navigation/native';


const Tweets = () => (
  <Screen>
    <Text>Tweets</Text>
  </Screen>
);

const TweetDetails = () => (
  <Screen>
    <Text>Tweet Details</Text>
  </Screen>
);

const Stack = createStackNavigator();

const StackNavigator = () => (
  <StackNavigator>
    <Stack.Screen name="Tweets" component={Tweets} />
    <Stack.Screen name="TweetDetails" component={TweetDetails} />
  </StackNavigator>
);

export default function App() {
  return (
    <NavigationContainer>
      <StackNavigator />
    </NavigationContainer>
    )
}

Please help me find the source of the problem, thanks!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This block has StackNavigator as being recursive.

const StackNavigator = () => (
  <StackNavigator>
    <Stack.Screen name="Tweets" component={Tweets} />
    <Stack.Screen name="TweetDetails" component={TweetDetails} />
  </StackNavigator>
);

Changing the inner StackNavigator to Stack.Navigator should resolve the problem.

const StackNavigator = () => (
  <Stack.Navigator>
    <Stack.Screen name="Tweets" component={Tweets} />
    <Stack.Screen name="TweetDetails" component={TweetDetails} />
  </Stack.Navigator>
);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!