在error
我进入我的iOS
模拟器对我没有意义。我的Home.js
组件对我来说似乎很好。我无法理解我是如何得到这个错误的。我清楚地导出了组件。我怎样才能摆脱这个错误?为什么我会收到“元素类型无效”错误?
这里的Home.js
:
import React from 'react';
import Container from 'native-base';
import {MapContainer} from "../../../components/MapContainer/index";
class Home extends React.Component {
componentDidMount() {
this.props.setName();
}
render() {
const region = {
latitude: 3.146642,
longitude: 101.695845,
latitudeDelta: 0.8922,
longitudeDelta: 0.0421
}
return(
<Container>
<MapContainer region={region}/>
</Container>
);
}
}
export default Home;
这里的index.js
:
import React from 'react';
import View from 'native-base';
import MapView from 'react-native-maps';
import styles from './MapContainerStyles';
export const MapContainer = ({region}) => {
return(
<View style={styles.container}>
<MapView
provider={MapView.PROVIDER_GOOGLE}
style={styles.map}
region={region}
>
</MapView>
</View>
);
}
这里的error
:
Element type is invalid: expected a string (for built-in components) or
a class/function (for composite components) but got: undefined. You
likely forgot to export your component from the file it's defined in.
Check the render method of 'Home'.
ahhh我明白了。谢谢! – hop38
我完全理解了这个概念。但是每当我尝试在我的代码中实现这一点。出于某种原因,我仍然得到同样的错误。 – hop38
你可以请你展示你的更新代码吗? –