Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在业务代码里面如何获取navigator的引用呢? #9

Open
huadong1989 opened this issue Apr 22, 2016 · 1 comment
Open

在业务代码里面如何获取navigator的引用呢? #9

huadong1989 opened this issue Apr 22, 2016 · 1 comment

Comments

@huadong1989
Copy link

在业务代码里面如何获取navigator的引用呢?
比如我在初始化的代码如下:
<CLNavigator initialRoute={{ name:"home", page:() => <Home/> }} />

那我如何在Home组建中获取到navigator得引用呢?

@cnsnake11
Copy link
Owner

cnsnake11 commented Apr 22, 2016

最简单同时也比较好的办法是使用global

<Navigator ref={(nav) => { global.nav = nav; }}/>

这样在整个rn模块里,你就可以直接使用global.nav了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants