I wrote a short code, basically copy paste of a tutorial, but for some reason when I try to use another js file, it gives me an error "None of these files exist" and a list of files.
I have includes a screenshort of the enite error
My code is just the basic structure of a React-Native app, using the blank tamplate, my only addon was the "import GoogleAuth from "./assets/code";" and ""
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import GoogleAuth from "./assets/code";
export default function App() {
return (
<View style={styles.container}>
<Text>Wele to dogappcoolapp app</Text>
<GoogleAuth/>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
and this is is GoogleAuth.js
import React from 'react'; import { StyleSheet, Text, View,Button } from 'react-native';
function GoogleAuth(props) {
return (
<div>
<Button
title ="sign up with google"
/>
</div>
);
}
export default GoogleAuth;
is , as you can see, the path seems correct so I don't know what can cause it, as in the tutorial I watched they did nothing difference (just with different names)
Why does it happen? I could not find any solution for it on gooogle, and I even went ahead and copy pasted a tutorial and got this error.
I wrote a short code, basically copy paste of a tutorial, but for some reason when I try to use another js file, it gives me an error "None of these files exist" and a list of files.
I have includes a screenshort of the enite error
My code is just the basic structure of a React-Native app, using the blank tamplate, my only addon was the "import GoogleAuth from "./assets/code";" and ""
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import GoogleAuth from "./assets/code";
export default function App() {
return (
<View style={styles.container}>
<Text>Wele to dogappcoolapp app</Text>
<GoogleAuth/>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
and this is is GoogleAuth.js
import React from 'react'; import { StyleSheet, Text, View,Button } from 'react-native';
function GoogleAuth(props) {
return (
<div>
<Button
title ="sign up with google"
/>
</div>
);
}
export default GoogleAuth;
is , as you can see, the path seems correct so I don't know what can cause it, as in the tutorial I watched they did nothing difference (just with different names)
Why does it happen? I could not find any solution for it on gooogle, and I even went ahead and copy pasted a tutorial and got this error.
Share Improve this question edited Jul 12, 2021 at 12:37 E_net4 30.1k13 gold badges114 silver badges151 bronze badges asked Jul 11, 2021 at 23:17 AccountOren3AccountOren3 731 silver badge5 bronze badges 3-
1
how about
import GoogleAuth from "./assets/code/GoogleAuth.js";
since that's a file you want to import from? as opposed to a folder, which isn't a file – Bravo Commented Jul 11, 2021 at 23:19 - Gives me a different error so it's better, why does it work when in the tutorial they didn't need to add js? – AccountOren3 Commented Jul 11, 2021 at 23:31
- Yes it works, thanks – AccountOren3 Commented Jul 11, 2021 at 23:37
2 Answers
Reset to default 2In your import GoogleAuth from "./assets/code"
you are pointing to a folder not a module/js file. It is possible if you have index.js
there but since it is not the case you should consider replacing it with
import GoogleAuth from "./assets/code/GoogleAuth.js"
Solved by changing
import GoogleAuth from "./assets/code";
to
import GoogleAuth from "./assets/code/GoogleAuth.js";
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745278234a4620155.html
评论列表(0条)