2

I am new to react and trying to create a map element that shows on the app. However I believe I am doing something wrong when I say I am exporting the default class App. This is the error I get "React.createElement: type is invalid -- expected a string (for built in components) or a class/function (for composite components) but got: "undefined"" I have my code below.

   import React from 'react';
   import { StyleSheet, Text, View } from 'react-native';
   import { MapView } from 'expo';

   export default class App extends React.Component {
     constructor(props) {
        super(props);

        this.state = {
          region: {
              latitude: 37.78825,
              longitude: -122.4324,
              latitudeDelta: 0.922,
              longitudeDelta: 0.0421,
           }
         }
       }  
   render() {  
       return (
         <View style={styles.container}>
          <Text>Home Sreen</Text>
          <MapView
            initialRegion={this.state.region}
            showsCompass={true}
            rotateEnabled={false}
            style={{flex: 1}}
         />
       </View>
      );
    }
   }
   const styles = StyleSheet.create({
      container: {
      flex: 1,
      backgroundColor: '#fff',
   },
   });
GMccread
  • 23
  • 5

2 Answers2

1

Instead of

import { MapView } from 'expo';

use

import MapView from 'react-native-maps';
SDushan
  • 4,341
  • 2
  • 16
  • 34
-1

Try removing export default from class and add it on the last line of your program

Export default appname;
Logesh P
  • 209
  • 4
  • 18