AR *_*ond 2 react-native react-native-maps
显示地图我使用react-native-maps。我做了所有配置,但是当运行我的项目时,在控制台中收到以下消息:
允许需要循环,但可能导致未初始化的值。考虑重构以消除对循环的需要。需要循环: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
我认为此消息会导致问题,并且不允许应用程序显示地图。我该如何解决这个问题?
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>
)
}
Run Code Online (Sandbox Code Playgroud)
我使用itsam在这个Github问题中的答案解决了这个问题,括号中是我更详细的说明,假设您位于您的根目录中package.json:
- 安装补丁包(
npm i -D patch-package或yarn add -D patch-package)。- 在您的项目中创建一个名为“patches”的文件夹 (
mkdir patches)- 在“patches”文件夹内从这个要点获取补丁(为方便起见)https://gist.github.com/itsam/278a56a1f20a8b80e27c269d9fe83093 并将其命名为 react-native-maps+0.27.1.patch (复制并粘贴gist URL 中的补丁文件到
patches/react-native-maps+0.27.1.patch)- 在
package.json,包括"postinstall": "patch-package"在下面script(作者忘记包括这个重要步骤)yarn install或者npm install(它可能会发出警告说版本不匹配,但它对我有用)
| 归档时间: |
|
| 查看次数: |
1529 次 |
| 最近记录: |