简体   繁体   中英

Undefined in react-native after importing

I'm developing an app and I was almost finished, when I found this module: react-native-ui-kitten

When I use the components, it works properly, but I saw that the have an example app: kittenTricks

In this app, there is an interessant way to handle the routes.

But when I implement it, I get weird error.

I import the Screens, this way: import * as Screens from '../../screens/index';

and when I print it in the console I get this:

在此处输入图片说明

So, it seems to me, as it's importing the whole Screens. When I click in GridV2 I can see the object.

But

When I use: Screens.GridV2 then I get undefined and the same happens with every screen, so I don't have a clue.

GridV2 is so exported: export class GridV2 extends

And then, there's an index file which exports again: export * from './grid2' and then the index of screens.

Apparently, it is working, otherwise I couldn't see the objects when I print Screens but then, why Screens.whatever is giving an undefined ?

I checked the dependencies, that they use in the example app, and they are the same as the dependencies I have. react and react-native are different versions, but I hope there's a way to get the objects of Screens in react-native: 0.49.3

I mean, I don't have a clue why it's happening, I was just wondering if there is a problem with the version of react-native.

Maybe someone had a similar problem and can tell me how to fix it. It's really making me crazy .

I didn't find the answer I was looking for, and I asume it's not possible to do it that way. That's why the answer "I found" is just importing one by one the modules:

import gridV2 from '../../screens/navigation/grid2';
import sideMenu from '../../screens/navigation/sideMenu';

and then

        {
            id: 'GridV2',
            title: 'Grid Menu V2',
            screen: gridV2,
            children: []
        },

other side, I find this way better for reading.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM