Home > Software engineering >  Element type Invalid React Native
Element type Invalid React Native

Time:01-14

I just created a project and I m getting this error. No dependencies installed yet

import { StatusBar } from "expo-status-bar";
import {
  StyleSheet,
  Text,
  View,
  Container,
  Header,
  Title,
  Button,
  Left,
  Right,
  Body,
  Icon,
} from "react-native";

export default function App() {
  return (
    <Container>
      <Header>
        <Body>
          <Title></Title>
        </Body>
      </Header>
    </Container>
  );
}

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of `App`.

This error is located at: in RCTView (created by View) in View (created by App) in App (created by ExpoRoot) in ExpoRoot in RCTView (created by View) in View (created by AppContainer) in RCTView (created by View) in View (created by AppContainer) in AppContainer

CodePudding user response:

Did you create project using expo or react-native-cli and have you changed anything after creating the project?

If this is the expo cli you can try closing the metrol bundler and running npm install in your terminal then starting it again.

If this is react-native-cli you can try running.

npm install
cd ios && pod install
cd ..

CodePudding user response:

try running this commands

 cd android
./gradlew clean
npm install
  •  Tags:  
  • Related