无法解析从 “App.js” 导入的 “./src/screens/authScreens/SignInScreen”。

huangapple go评论59阅读模式
英文:

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 &quot;react-native&quot;;
import { colors, parameters } from &quot;./src/global/styles&quot;;

import SignInScreen from &quot;./src/screens/authScreens/SignInScreen&quot;;

export default function App() {
  return (
    &lt;View&gt;
      &lt;StatusBar barStyle=&quot;light-content&quot; backgroundColor={colors.statusbar} /&gt;
      &lt;SignInScreen /&gt;
    &lt;/View&gt;
  );
}

const styles = StyleSheet.create({});

无法解析从 “App.js” 导入的 “./src/screens/authScreens/SignInScreen”。

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 &quot;react&quot;;
import { View, Text, StyleSheet, Dimensions } from &quot;react-native&quot;;
import { colors, parameters } from &quot;../../global/styles&quot;;
import Icon from &quot;react-native-vector-icons/Ionicons&quot;;
import Header from &quot;../../components/Header&quot;;

export function SignInScreen() {
return (
    &lt;View style={styles.container}&gt;
    &lt;Header title={&quot;MY ACCOUNT&quot;} type={&quot;caret-back&quot;} /&gt;
    &lt;Text&gt;hello to world&lt;/Text&gt;
    &lt;/View&gt;
);
}
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 &quot;./src/screens/authScreens/SignInScreen&quot;;

if you're not use export default, use below import with {}

export function SignInScreen() {

//use below import with {}
import {SignInScreen} from &quot;./src/screens/authScreens/SignInScreen&quot;;    

答案2

得分: 0

import {SignInScreen} from "./src/screens/authScreens/SignInScreen";

英文:

import like this

import {SignInScreen} from "./src/screens/authScreens/SignInScreen";

huangapple
  • 本文由 发表于 2023年2月27日 13:05:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/75576920.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定