在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
你可以請你展示你的更新代碼嗎? –