Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Navigation, Issue finding files

Im brand new to React Native and am struggling with something basic, Trying to divide my app into different files (new file per screen) but my navigator cant find the screens or something. Im 90% sure its a pretty basic mistake but have been stuck on it for an embarrassing amount of time.

Here's the Error:

'' Couldn't find a 'component','getComponent' or 'children prop" for screen 'details'

Im pretty sure I did my import/export correctly but obviously something is wrong.

Code:

//component import (app.js)

import { DetailScreen } from './screens/2nd';
...
...

//stack(app.js)

export default function App() {

  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName='home'>
        <Stack.Screen name='home' component={HomeScreen} />
        <Stack.Screen name='details' component={DetailScreen} />

      </Stack.Navigator>
    </NavigationContainer>
  );
}



//details page (2nd.js):

const DetailScreen = () => {
    return (
        <View>
            <Text>
                Detail Screen
        </Text>
        </View>
    )
}

export default DetailScreen;
like image 744
Marko Avatar asked Sep 21 '26 13:09

Marko


1 Answers

Change

import { DetailScreen } from './screens/2nd'; 

to

import  DetailScreen  from './screens/2nd';

https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export#Description

like image 108
Nisuga Jayawardana Avatar answered Sep 23 '26 03:09

Nisuga Jayawardana



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!