Require cycles are allowed, but can result in uninitialized values in react-native-maps

Viewed 2010

to show map I use react-native-maps. I did all config but when run my project get the following message in the console:

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. Require cycle: node_modules\react-native-maps\lib\components\MapView.js -> node_modules\react-native-maps\lib\components\Geojson.js -> node_modules\react-native-maps\lib\components\MapView.js

I think this message causes a problem and does not allow the app to show the map. How can I solve this?

import MapView, { PROVIDER_GOOGLE } from 'react-native-maps'
import React from 'react'
import { View, Text, StyleSheet } from 'react-native'
    const App = () => {
      return (
        <View style={styles.container}>
          <MapView
            provider={PROVIDER_GOOGLE} // remove if not using Google Maps
            style={styles.map}
            region={{
              latitude: 37.78825,
              longitude: -122.4324,
              latitudeDelta: 0.0922,
              longitudeDelta: 0.0421,
            }}
          >
          </MapView>
        </View>
      )
    }
1 Answers

I resolved this issue using an answer in this Github issue by itsam, with my more detailed instructions in the brackets, assuming you are at your root directory where package.json is:

  1. install patch-package (npm i -D patch-package or yarn add -D patch-package).
  2. create a folder in your project called "patches" (mkdir patches)
  3. Inside "patches" folder get the patch from this gist (for convenience) https://gist.github.com/itsam/278a56a1f20a8b80e27c269d9fe83093 and name it as react-native-maps+0.27.1.patch (copy and paste the contents of the patch file in the gist URL to patches/react-native-maps+0.27.1.patch)
  4. In package.json, include "postinstall": "patch-package" under script(The writer forgot to include this important step)
  5. yarn install or npm install (it may throw a warning saying that the versions are mismatched, but it works for me)
Related