javascript - 即使我没有使用它,也无法在 react-native 中找到变量错误
问题描述
所以我正在学习 React-Native 并且我创建了一个之前已经工作过的抽屉。但是经过一些不涉及 Drawer 的修改后,Can't find variable: Contact
即使我没有导入名为Contact
.
抽屉.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;
联系人.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);
通过堆栈跟踪,错误来自抽屉.js 第 6 行,我在其中导入Contacts
而不是Contact
. 我已经跑去npm start -- --reset-cache
看看它是否能解决它,但没有。我很困惑为什么会这样。
解决方案
推荐阅读
- oracle12c - 从 Select 语句调用 Oracle 存储过程?
- bdd - 如何使用 QAF API 管理 Gherkin 中实现的步骤的响应数据?
- python - 如何在 Django 中以更新形式显示数据库中已有的数据?
- git - gitignore 所有带有扩展模式的文件
- ios - 从后台线程调用 ARKit UIView setAnimationsEnabled
- r - 双向重复测量方差分析:lm.fit() 中的错误... 0 个非 na 案例 (rstatix)
- javascript - Nightwatch - 设置和获取全局变量
- c# - 得到“运行 docker.exe 登录命令失败。” 在尝试发布到 Azure 容器注册表时
- perl - Devel::Cover - 在程序结束前保存覆盖数据
- azure-devops - Azure DevOps - 选择不同的 IterationPath(工作项表)