英文:
Unable to resolve "./src/screens/authScreens/SignInScreen" from "App.js"
问题
App.js:
import { StyleSheet, Text, View, StatusBar } from "react-native";
import { colors, parameters } from "./src/global/styles";
import SignInScreen from "./src/screens/authScreens/SignInScreen";
export default function App() {
return (
<View>
<StatusBar barStyle="light-content" backgroundColor={colors.statusbar} />
<SignInScreen />
</View>
);
}
const styles = StyleSheet.create({});
SignInScreen:
import React from "react";
import { View, Text, StyleSheet, Dimensions } from "react-native";
import { colors, parameters } from "../../global/styles";
import Icon from "react-native-vector-icons/Ionicons";
import Header from "../../components/Header";
export function SignInScreen() {
return (
<View style={styles.container}>
<Header title="MY ACCOUNT" type="caret-back" />
<Text>hello to world</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
注意:翻译中的HTML标记已被移除。
英文:
App.js:
import { StyleSheet, Text, View, StatusBar } from "react-native";
import { colors, parameters } from "./src/global/styles";
import SignInScreen from "./src/screens/authScreens/SignInScreen";
export default function App() {
return (
<View>
<StatusBar barStyle="light-content" backgroundColor={colors.statusbar} />
<SignInScreen />
</View>
);
}
const styles = StyleSheet.create({});
I want to import SignInScreen component from SignInScreen but it shows error
"" Unable to resolve "/src/screens/authScreens/SignInScreen" from "App.js"""
SignInScreen:
import React from "react";
import { View, Text, StyleSheet, Dimensions } from "react-native";
import { colors, parameters } from "../../global/styles";
import Icon from "react-native-vector-icons/Ionicons";
import Header from "../../components/Header";
export function SignInScreen() {
return (
<View style={styles.container}>
<Header title={"MY ACCOUNT"} type={"caret-back"} />
<Text>hello to world</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
答案1
得分: 2
如果您使用export default
函数,请使用以下导入:
import SignInScreen from "./src/screens/authScreens/SignInScreen";
如果您没有使用export default
,请使用以下导入方式,带有花括号 {}
:
import { SignInScreen } from "./src/screens/authScreens/SignInScreen";
英文:
if you use export default function, use below import
export default function SignInScreen() {
//use below import
import SignInScreen from "./src/screens/authScreens/SignInScreen";
if you're not use export default, use below import with {}
export function SignInScreen() {
//use below import with {}
import {SignInScreen} from "./src/screens/authScreens/SignInScreen";
答案2
得分: 0
import {SignInScreen} from "./src/screens/authScreens/SignInScreen";
英文:
import like this
import {SignInScreen} from "./src/screens/authScreens/SignInScreen";
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论