gpt4 book ai didi

reactjs - 设置选项卡导航器时出错 - ' Got an invalid Value for ' 组件的屏幕 'Home' Prop

转载 作者:行者123 更新时间:2023-12-04 14:33:59 25 4
gpt4 key购买 nike

我目前收到错误消息,屏幕“主页”的“组件” Prop 的值无效。它必须是一个有效的 React 组件。'' 我正在尝试将选项卡导航器链接到一系列不同的屏幕。请参阅下面的代码并提前致谢。我显然是初学者哈哈

import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';

import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import {NavigationContainer} from '@react-navigation/native';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'
import { create } from 'react-test-renderer';
import HomePage from './Screen/Home'
import FuturePage from './Screen/Future'

const Tabs=createBottomTabNavigator();

export default function App (){

return (
<NavigationContainer>
<Tabs.Navigator>
<Tabs.Screen name='Home' component={HomePage} />
<Tabs.Screen name='Future' component={FuturePage} />
</Tabs.Navigator>
</NavigationContainer>
);
}



主页屏幕

import React, { Component } from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'

import Icon from 'react-native-vector-icons/Ionicons';

import { AppRegistry,
View,
Text,
ScrollView,
Image,
StyleSheet,
ImageBackground,
Animated, Easing
} from 'react-native';

export default class HomePage extends React.Component {

render() {
return(
<View style={styles.container}>

<ScrollView>
<View
style={[styles.tbcViews, {top: 600}, {left: 25} ]}
/>
<View
style={[styles.tbcViews, {top: 950}, {left: 200} ]}
/>
<View
style={[styles.tbcViews, {top: 1200}, {left: 600} ]}
/>
<View
style={[styles.tbcViews, {top: 600}, {left: 700} ]}
/>
<View
style={[styles.tbcViews, {top: 1400}, {left: 250} ]}
/>
<View
style={[styles.tbcViews, {top: 950}, {left: 900} ]}
/>
<View
style={[styles.tbcViews, {top: 1500}, {left: 1000} ]}
/>
<View
style={[styles.tbcViews, {top: 1100}, {left: 1300} ]}
/>
<View
style={[styles.tbcViews, {top: 400}, {left: 1200} ]}
/>
<View
style={[styles.tbcViews, {top: 1650}, {left: 650} ]}
/>
<View
style={[styles.tbcViews, {top: 1750}, {left: 75} ]}
/>


<Image style={{resizeMode: 'repeat', height:2000, width:1500}}
source={require('./assets/CurtainBG.png')}
/>


</ScrollView>

<Image
style={styles.logo_title}
source={require('./assets/Logo_Title.png')}
/>
<Text
style={styles.mini_titles}>FUTURE</Text>
<Text
style={styles.mini_titles2}>PAST</Text>
<Icon
style={styles.arrows}
name="ios-arrow-up" size={20} />
<Icon
style={styles.arrowdown}
name="ios-arrow-down" size={20} />
<Image
style={styles.futureicon}
source={require('./assets/FutureIconBlue.png')}
/>
</View>
);
};
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
height: 500,
width: 450,
left: -25

},
logo_title: {
position: 'absolute',
alignItems: 'center',
top:400,
zIndex: 10,
width: 450,
height: 150,
},
mini_titles: {
position: 'absolute',
alignItems: 'center',
justifyContent: 'center',
zIndex: 12,
top: 350,

},
mini_titles2: {
position: 'absolute',
alignItems: 'center',
justifyContent: 'center',
zIndex: 12,
top: 550,

},
arrows: {
position: 'absolute',
alignItems: 'center',
justifyContent: 'center',
zIndex: 12,
top: 300,

},
arrowdown: {
position: 'absolute',
alignItems: 'center',
justifyContent: 'center',
zIndex: 12,
top: 600,

},
futureicon: {
position: 'absolute',
alignItems: 'center',
justifyContent: 'center',
zIndex: 12,
top: 85,
height: 190,
width: 190


},

tbcViews: {
position: 'absolute',
alignItems: 'center',
zIndex: 10,
width: 200,
height: 200,
borderWidth:2.5,
borderStyle: 'dotted',
borderColor:'rgb(27, 63, 143)',
borderRadius: 10
},

})


最佳答案

如果您不导出组件,也会发生这种情况
检查以下内容

export default HomePage

关于reactjs - 设置选项卡导航器时出错 - ' Got an invalid Value for ' 组件的屏幕 'Home' Prop ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62040832/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com