gpt4 book ai didi

javascript - react native MapView : undefined is not an object

转载 作者:行者123 更新时间:2023-11-28 03:56:46 25 4
gpt4 key购买 nike

我是 React Native 的初学者,我正在尝试使用“react-native-maps”模块中的 MapView 组件。

这是我的代码:

import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
AppRegistry,
View
} from 'react-native';
import MapView from 'react-native-maps';


export default class LocationDisplay extends Component<{}> {

render() {
return (
<MapView/>
);
}
}

AppRegistry.registerComponent('LocationDisplay', () => LocationDisplay)

我收到此错误:

undefined is not an object (evaluating ‘_react.PropTypes.string’)

有人可以帮助我吗?

最佳答案

PropTypes 曾经包含在 React 中,但现在是一个单独的包。

npm i prop-types

更改自:

import React, { PropTypes, Component } from 'react';

import React, { Component } from 'react';
import PropTypes from 'prop-types';

使用示例:

class Item extends Component {
static propTypes = {
data: PropTypes.object.isRequired
};
}

关于javascript - react native MapView : undefined is not an object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47500469/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com