Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

323
Visualizações
React native/navigation error displaying component/component is undefined

I was a little bored of react-js recently and wanted to try react native, I followed a tutorial on youtube which used react navigation, and I got an error at the very beggining of creating my app (while creating my first component actually)

  • First I got an error saying Text strings must be rendered within a <Text> component. but my string was in a text component

  • Then I tried doing a component which just return en empty <View></View> but got an error :

variant Violation: View config getter callback for component `div` must be a function (received `undefined`) I concluded the error was coming from the component itself and not the text

  • Finaly I saw on a forum it could comme from a bad import, even if I was sure it was imported correctly I tried declaring my component inside my app.js so no import would be required, but the same errors happen

Here is my code :

import { createStackNavigator } from "@react-navigation/stack";
import { NavigationContainer} from "@react-navigation/native";
import { View } from "react-native-web";

const Stack = createStackNavigator();

const Home = () => {
  return (
    <View>
      <Text>Home</Text>
    </View>
  );
};


const App = () => {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Home">
        <Stack.Screen name="Home" component={Home} />
      </Stack.Navigator>
    </NavigationContainer>
  );
};

export default App;

In the tutorial I was following the guy used react navigation 6 but called the function createStackNavigator()

In the official documentation https://reactnavigation.org/docs/hello-react-navigation they use createNativeStackNavigator instead of createStackNavigator (which is for v5), I tried deleting my node modules, installing the correct npm package, verified the versions, and then followed this documentation but I still get the same errors

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You should be using createNativeStackNavigator instead, and you also need to import Text since you only have View. Be sure to import React Native components from 'react-native' instead of 'react-native-web'. Doing all of this fixed your issue and I can now see the text displayed:

import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { NavigationContainer } from "@react-navigation/native";
import { View, Text } from "react-native";

const Stack = createNativeStackNavigator();

const Home = () => {
    return (
        <View>
            <Text>Home</Text>
        </View>
    );
};

const App = () => {
    return (
        <NavigationContainer>
            <Stack.Navigator initialRouteName="Home">
                <Stack.Screen name="Home" component={Home} />
            </Stack.Navigator>
        </NavigationContainer>
    );
};

export default App;
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda