本文介绍了createStackNavigation不变违规元素类型无效,预期为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在创建导入并使用createStackNavigation时,出现以下错误.任何帮助将不胜感激!另外,这是我的第一个应用程序,请耐心等待.
Upon creating importing and using createStackNavigation I'm getting the following error. Any help would be greatly appreciated! Also, this is my first app in react-native so please be patient with me.
我已经尝试过其他版本的StackNavigation来阅读与该错误有关的其他帖子,但似乎没有一个让我无所适从.
I've tried other versions of StackNavigation read other posts relating to the error but none of them seem to get me anywhere.
import React, { Component } from "react";
import { Center } from "@builderx/utils";
import { View, StyleSheet, Image, Text } from "react-native";
import { createAppContainer } from 'react-navigation';
import { MainNavigation } from '../screens/MainNavigator';
const AppContainer = createAppContainer(MainNavigation);
export default class DlLoading_2 extends Component {
render() {
return (
<View style={styles.root}>
<Center />
<AppContainer
TouchableHighlight onPress={() =>
this.navigation.navigate('DlMain')}>
Image style={styles.blueDisk} source= .
{require('../assets/ComponentTMP_0-image.jpg')} />
</AppContainer>
<Center horizontal>
<Image
source={require("../assets/ComponentTMP_0-image2.png")}
style={styles.dlLogo}
/>
</Center>
<Center horizontal>
<Text style={styles.text}>TRANSINDENTAL MEDITATION</Text>
</Center>
</View>
);
}
}
const styles = StyleSheet.create({
root: {
backgroundColor: "#FFFFFF",
flex: 1
},
blueDisk: {
height: 401.5,
width: 602,
position: "absolute"
},
dlLogo: {
height: 97,
width: 300,
position: "absolute",
top: "6.61%"
},
text: {
height: 53,
width: 301,
top: 660,
position: "absolute",
backgroundColor: "transparent",
lineHeight: 24,
letterSpacing: 0,
fontFamily: "Gotham-Book",
fontSize: 24,
textAlign: "center",
color: "rgba(92,92,95,1)"
}
});
这也是我的MainNavigator.js:
Here is my MainNavigator.js too:
import DlLoading_2 from "./src/screens/DlLoading_2";
import DlMain from "./src/screens/DlMain";
import { createStackNavigator, createAppContainer } from "react-
navigation";
import { create } from "handlebars";
const MainNavigator = createStackNavigator({
DlLoading_2: {
screen: DlLoading_2
},
DlMain: {
screen: DlMain
}
},
{
headerMode: "none"
}
);
export default createAppContainer(MainNavigator);
推荐答案
导出默认值"并使用{}或不使用{} 导入的问题.
更改此行
import { MainNavigation } from '../screens/MainNavigator';
到(去掉大括号)
import MainNavigation from '../screens/MainNavigator';
这篇关于createStackNavigation不变违规元素类型无效,预期为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!