Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/460.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么我会得到;元素类型无效";错误?_Javascript_Ios_Reactjs_Debugging_React Native - Fatal编程技术网

Javascript 为什么我会得到;元素类型无效";错误?

Javascript 为什么我会得到;元素类型无效";错误?,javascript,ios,reactjs,debugging,react-native,Javascript,Ios,Reactjs,Debugging,React Native,在错误中我进入的iOS模拟器对我来说没有意义。我觉得我的Home.js组件很好。我不明白我怎么会犯这个错误。我已经清楚地导出了组件。我怎样才能消除这个错误 这里是Home.js: import React from 'react'; import Container from 'native-base'; import {MapContainer} from "../../../components/MapContainer/index"; class Home extends React.C

错误中
我进入的
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;
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>
    );
}
下面是
错误

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'.

你们这里有两个出口

import React from 'react';
import View from 'native-base';
import MapView from 'react-native-maps';
import styles from './MapContainerStyles';

//delete export from the next line
export const MapContainer = ({region}) => {
    return(
        <View style={styles.container}>
            <MapView
                provider={MapView.PROVIDER_GOOGLE}
                style={styles.map}
                region={region}
            >
            </MapView>
        </View>
    );

}

export default MapContainer;
从“React”导入React;
从“本机基础”导入视图;
从“react native maps”导入MapView;
从“/MapContainerStyles”导入样式;
//从下一行删除导出
导出常量映射容器=({region})=>{
返回(
);
}
导出默认映射容器;

这里有两个导出

import React from 'react';
import View from 'native-base';
import MapView from 'react-native-maps';
import styles from './MapContainerStyles';

//delete export from the next line
export const MapContainer = ({region}) => {
    return(
        <View style={styles.container}>
            <MapView
                provider={MapView.PROVIDER_GOOGLE}
                style={styles.map}
                region={region}
            >
            </MapView>
        </View>
    );

}

export default MapContainer;
从“React”导入React;
从“本机基础”导入视图;
从“react native maps”导入MapView;
从“/MapContainerStyles”导入样式;
//从下一行删除导出
导出常量映射容器=({region})=>{
返回(
);
}
导出默认映射容器;

您的
映射容器中有2个导出

在顶部有一个
export const MapContainer

你在底部有一个<代码>导出默认映射容器

现在您需要删除一个,但保留的一个将决定以后如何导入它

如果保留默认导出,则按此方式导入

从“../../../components/MapContainer/index”导入MapContainer

如果保留非默认导出,则会像这样导入


从“../../../components/MapContainer/index”导入{MapContainer}”

您的
映射容器中有2个导出

在顶部有一个
export const MapContainer

你在底部有一个<代码>导出默认映射容器

现在您需要删除一个,但保留的一个将决定以后如何导入它

如果保留默认导出,则按此方式导入

从“../../../components/MapContainer/index”导入MapContainer

如果保留非默认导出,则会像这样导入


从“../../../components/MapContainer/index”导入{MapContainer}”

啊,我明白了。非常感谢。我完全理解这个概念。但每当我试图在代码中实现这一点时。由于某些原因,我仍然收到相同的错误。现在在我的原始帖子中发布了它不确定。我只是想重现你的场景,对我来说效果很好。对不起,我明白了。非常感谢。我完全理解这个概念。但每当我试图在代码中实现这一点时。由于某些原因,我仍然收到相同的错误。现在在我的原始帖子中发布了它不确定。我只是想重现你的场景,对我来说效果很好。很抱歉