Ahmad Shoukat
Ahmad Shoukat

Reputation: 31

react-native-maps with expo , native-only module

am new to react native and am trying to use react-native-maps. am using expor and added maps by command form expo docs which is "npm expo install react-native-maps" (it also gave me a warning "Warning: react-native-maps does not support the New Architecture." am unable to use react native maps. it says "InternalError Metro has encountered an error: Importing native-only module"

i tried adding this code in node_modules/react-native which i got from documentation of react-native-maps :

  project: {
    android: {
      unstable_reactLegacyComponentNames: [
        'AIRMap',
        'AIRMapCallout',
        'AIRMapCalloutSubview',
        'AIRMapCircle',
        'AIRMapHeatmap',
        'AIRMapLocalTile',
        'AIRMapMarker',
        'AIRMapOverlay',
        'AIRMapPolygon',
        'AIRMapPolyline',
        'AIRMapUrlTile',
        'AIRMapWMSTile',
      ],
    },
    ios: {
      unstable_reactLegacyComponentNames: [
        'AIRMap',
        'AIRMapCallout',
        'AIRMapCalloutSubview',
        'AIRMapCircle',
        'AIRMapHeatmap',
        'AIRMapLocalTile',
        'AIRMapMarker',
        'AIRMapOverlay',
        'AIRMapPolygon',
        'AIRMapPolyline',
        'AIRMapUrlTile',
        'AIRMapWMSTile',
      ],
    },
  },
};

i guess this is to resolve the new architecture support issue

but am still getting that error "InternalError Metro has encountered an error: Importing native-only module"

i tried looking into web to find solution but i can't find any

the version are :

    "expo": "^52.0.25",
    "expo-constants": "^17.0.4",
    "expo-linking": "^7.0.4",
    "expo-router": "^4.0.16",
    "expo-status-bar": "^2.0.1",
    "nativewind": "^4.1.23",
    "react": "18.3.1",
    "react-native": "^0.76.6",
    "react-native-safe-area-context": "4.12.0",
    "react-native-screens": "^4.4.0",
    "react-native-web": "~0.19.13",
    "react-native-maps": "1.18.0"

any help regarding this issue will be very appreciated

Upvotes: 0

Views: 282

Answers (1)

Ahmad Shoukat
Ahmad Shoukat

Reputation: 31

Found the error. i was running the app on my web device (beacuse am a web developer and found it more convinent to test there). and for web and mobile both we have the use different lib @teovilla/react-native-web-maps the detailed problem and its answer is here

Map for React Native Web With Expo and Metro

Upvotes: 0

Related Questions