reactjs - React Native - 元素类型无效(简单页面视图)
问题描述
我对 React Navigator 有疑问,我对 react native 很陌生,许多解决方案似乎与我的主要问题相去甚远。我已经按照文档所说的那样密切关注。无论如何我仍然会收到此错误:
错误:元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件),但得到:数字。
检查
Splash
.
这是我的 App.js
import * as React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import Splash from './pages/Splash';
function HomeScreen() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home Screen</Text>
</View>
);
}
const Stack = createStackNavigator();
function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Splash" component={Splash} />
</Stack.Navigator>
</NavigationContainer>
);
}
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
快速导入 Splash.js
import React from 'react'
import { StyleSheet, Text, View } from 'react-native'
import { ILLogo } from '../assets'
const Splash = () => {
return (
<View style={styles.page}>
<ILLogo />
<Text style={styles.title}>Hooray!!!</Text>
</View>
)
}
export default Splash;
const styles = StyleSheet.create({
page: {
backgroundColor: '#2BA3DC',
flex: 1,
alignItems: 'center',
flexDirection: 'column',
justifyContent: 'center'
},
title: {
fontSize: 20,
fontWeight: '600',
color: '#fff',
marginTop: 20
}
});
我试图通过多种方式导出splash并将其导入,请帮助我
解决方案
推荐阅读
- python - 如果和语句在 Python 中没有输出准确的结果
- url-redirection - 如何将所有访问者引导至 https://www.example.com?
- javascript - 一键选择文件上传
- python - 窗口截图 Python Arcade 库
- r - 需要使列显示哪些 ID 分配给这些列...不知道如何描述
- c# - 如何将嵌套的三元运算符转换为嵌套的 if-else 语句?
- php - 将数据库查询减少到一个并避免在 null 错误时调用成员函数 load()
- unix - 如何在 Csh 中向自身添加变量
- lua - lua eventListener 调用方法四次而不是一次
- java - lambda 函数中的 Spring Retry 似乎不起作用