typescriptreact-native

error in React Native with the command: npm run reset-project


I'm following Expo start developing. When I try npm run reset-project I get error 500 in my app. The problem is a file that is created: +not-found.tsxenter image description here

In the file:

import { StyleSheet } from 'react-native';

import { ThemedText } from '@/components/ThemedText';
import { ThemedView } from '@/components/ThemedView';

export default function NotFoundScreen() {
 return (
   <>
     <Stack.Screen options={{ title: 'Oops!' }} />
     <ThemedView style={styles.container}>
       <ThemedText type="title">This screen doesn't exist.</ThemedText>
       <Link href="/" style={styles.link}>
         <ThemedText type="link">Go to home screen!</ThemedText>
       </Link>
     </ThemedView>
   </>
 );```
there is an error in
```return (<>``` 
and VS givs a quick fix 
```Import React from react```. 
It leaves me with two more error: 
```import { ThemedText } from '@/components/ThemedText';
import { ThemedView } from '@/components/ThemedView';
``` Solved by ChatGPT ```'../components/ThemedView';```
Now wnen I import pictures I have to use ```source={require(@/path-to-image.jpg")}```.

Can anyone explain??? Ps. I have only worked with React i 3 month, so please not too complicated!

Solution

  • You have to import React like this:

    import React from 'react'

    Then, you have to modify path for {ThemedText} & {ThemedView}.

    I am using relative paths, so pls check this example.

    import { ThemedText } from '../components/ThemedText';
    import { ThemedView } from '../components/ThemedView';
    

    Hope this helps you out :)