即使我不使用它,也无法在react-native中找到变量错误

时间:2018-11-21 16:38:48

标签: javascript reactjs react-native

因此,我正在学习React-Native,并创建了一个之前可用的Drawer。但是经过一些不涉及抽屉的修改后,即使我没有导入名为Can't find variable: Contact的变量,它也会不断给出此错误Contact

drawer.js

import React, { Component } from 'react';
import { Text, View } from 'react-native';
import { DrawerNavigator, DrawerItems } from 'react-navigation';
import ButtonScreen from '../screens/ButtonScreen';
import Contacts from '../screens/Contacts';
import Information from '../screens/Information';
import Preferences from '../screens/Preferences';

const Drawer = new DrawerNavigator({
    Home: {
        screen: ButtonScreen,
        navigationOptions: {
            drawerLabel: 'Button'
        },
    },
    Contacts: {
        screen: Contacts,
    },
    Preferences: {
        screen: Preferences,
    },  
    Info: {
        screen: Information,
    }
}, {
    contentComponent: (props) => (
        <View>
            <Text>Custom Header</Text>
            <DrawerItems {...props}/>
            <Text>Custom Footer</Text>
       </View>
    )
});

export default Drawer;

Contacts.js

import React, { Component } from 'react';
import { connect } from 'react-redux';
import { View, Text } from 'react-native';

class Contacts extends Component {
     constructor(props) {
         super(props);
     }

    render() {
        return (
            <View>
                <Text>
                    Contact Component
                </Text>
            </View>
        );
    }
}

const mapStateToProps = (state) => {
    const { isDrawerOpened } = state;
    return { isDrawerOpened };
}

export default connect(mapStateToProps)(Contacts);

通过stacktrace,错误从来自我导入Contacts而不是Contact的draft.js第6行来。我已经运行过npm start -- --reset-cache来查看它是否可以解决问题,但是没有。我对为什么会这样感到很困惑。

0 个答案:

没有答案