错误警告:React.createElement:类型无效——需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)

问题描述 投票:0回答:0

我是 React Native 的新手,我正在尝试测试 geojson 库,但我遇到了这个错误。

我在从存储库复制的 app.js 和 package.json 代码下方发送了https://github.com/react-native-maps/react-native-maps/blob/master/docs/geojson.md .

App.js

import React from 'react';
import MapView, {Geojson} from 'react-native-maps';

const myPlace = {
  type: 'FeatureCollection',
  features: [
    {
      type: 'Feature',
      properties: {},
      geometry: {
        type: 'Point',
        coordinates: [64.165329, 48.844287],
      }
    }
  ]
};

const Map = props => (
  <MapView>
    <Geojson 
      geojson={myPlace} 
      strokeColor="red"
      fillColor="green"
      strokeWidth={2}
    />
  </MapView>
);

package.json


{
  "name": "geojsonvalidation",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "expo": "~48.0.6",
    "expo-app-loading": "^2.1.1",
    "expo-asset": "^8.9.1",
    "expo-font": "^11.1.1",
    "expo-status-bar": "~1.4.4",
    "geojson": "^0.5.0",
    "react": "18.2.0",
    "react-native": "0.71.3",
    "react-native-maps": "1.3.2"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "private": true
}

我只是想验证一个可能的未来解决方案。

react-native geojson react-native-maps mapview
© www.soinside.com 2019 - 2024. All rights reserved.