[英]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 我正在开发一个应用程序,当我找到以下模块时,我快要完成了: react-native-ui-kitten
When I use the components, it works properly, but I saw that the have an example app: kittenTricks 当我使用这些组件时,它可以正常工作,但是我看到有一个示例应用程序: kitchenTricks
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';
我以这种方式
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. 当我在
GridV2
单击时,我可以看到该对象。
But 但
When I use: Screens.GridV2
then I get undefined and the same happens with every screen, so I don't have a clue. 当我使用:
Screens.GridV2
我将无法定义,并且每个屏幕都发生同样的情况,因此我没有任何线索。
GridV2
is so exported: export class GridV2 extends
GridV2
就是这样导出的: export class GridV2 extends
And then, there's an index
file which exports again: export * from './grid2'
and then the index
of screens. 然后,有一个
index
文件再次export * from './grid2'
: export * from './grid2'
,然后是屏幕的index
。
Apparently, it is working, otherwise I couldn't see the objects when I print Screens
but then, why Screens.whatever
is giving an undefined
? 显然,它正在工作,否则在打印
Screens
时我看不到对象,但是为什么Screens.whatever
给出了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
react
和react-native
是不同的版本,但是我希望有一种方法可以使Screens的对象成为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. 我的意思是,我不知道为什么会这样,我只是想知道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. 另一方面,我发现这种方式更适合阅读。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.