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

android白屏优化的问题 #31

Open
afinal opened this issue Jun 5, 2017 · 5 comments
Open

android白屏优化的问题 #31

afinal opened this issue Jun 5, 2017 · 5 comments

Comments

@afinal
Copy link

afinal commented Jun 5, 2017

博主,我想请教一个问题,你的这种方案可以很大程度上解决效率问题,但是,假如我们从native进入react的一个页面,只有我们第一次进入这个react页面的时候,react页面的生命周期(render,componentDidMount)会执行,接下来每次进入这个react页面生命周期都不会再执行,而是直接就把页面显示出来了,假如我们在进入react页面componentDidMount的时候进行请求数据操作,接下来的每次都不会更新数据,请问一下我该怎么解决这个问题?

@cnsnake11
Copy link
Owner

参考一下这个:#19

@afinal
Copy link
Author

afinal commented Jun 8, 2017

@cnsnake11 好的,非常感谢,试了一下你的第二种方案,速度确实快了很多,而且react页面的生命周期都可以正常执行。我现在还是用的你之前的方案,缓存了manager和view,只不过每次进入ReactActivity的时候都会发送一条通知,然后React 接受这条通知之后进行路由分发,也解决了React 页面无法刷新的问题。速度和你的差不多。


我想请教您另外一个问题,第一次进入React 页面的时候,自定义的NativeModule获取到的getCurrentActivity == null,请问这个问题您有遇到过吗?

@cnsnake11
Copy link
Owner

你的方案也可以,理论上可能性能会更好一点。

你说的getCurrentActivity == null,我们并没有遇到过这个问题。

@afinal
Copy link
Author

afinal commented Jun 19, 2017

到最后还是采用了你的方案,因为今天发现我的方案有点问题,先进入ReactActivity然后进入OtherActivity,然后打开新ReactActivity会报错,因为缓存的ReactView已经有了parent,所以我现在也采用你的不缓存View方案。但是会有一瞬间的白屏,请问还可以继续优化吗?

@cnsnake11
Copy link
Owner

一瞬间的白屏我还真没注意到,可能分手机吧。
我们现在线上就是这个方案,已经运行了很久了,比较稳定,没有别的特殊的处理手段了。

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