react-native - @expo/vector-icons 玩笑失败了
问题描述
我有一个包含@expo/vector-icons
该组件的组件,该组件正在运行,但开玩笑地失败了。注释掉图标时测试成功
错误信息
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, or you might have mixed up default and named imports.
测试组件.tsx
import React from "react";
import { Ionicons } from "@expo/vector-icons"
import { View } from "react-native"
const TestComponent = () => {
return(
<View>
<Ionicons />
</View>
)
}
export default TestComponent
测试组件.test.tsx
import React from 'react';
import TestComponent from '../../components/TestComponent';
import { render } from '@testing-library/react-native';
describe('test FacebookIcon component', () => {
it('renders correctly', () => {
const tree = render(<TestComponent />);
expect(tree).toMatchSnapshot();
});
});
包.json
"@expo/vector-icons": "^12.0.5",
"expo": "^42.0.0",
"react": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
"@testing-library/react-native": "^7.1.0",
解决方案
推荐阅读
- visual-studio-code - Visual Studio Code 扩展:将外部片段拖放到编辑器中
- c++ - STL 通用算法 - 范围元素类型到谓词参数类型的隐式转换
- python - 如何使用 Python 将多个 Excel 工作簿合并到一个工作簿中
- xaml - 无法关闭 Xamarin Forms 中单击事件的弹出窗口
- python - Python线性回归组合问题
- php - WooCommerce 的 Mailchimp:删除同步问题的订阅者标签
- amazon-s3 - AWS Glue 和 S3 访问点
- node.js - 如何在 CodeIgniter 4 中集成节点包?
- bash - Bash脚本完成后没有退出,为什么?
- angularjs - 健全性检查:是否可以在 HLS(m3u8)视频流和 angularjs 应用程序(ui)之间进行代理?