很抱歉这个冗长的标题。
下面是我的componentDidMount()函数
componentDidMount() {
Linking.getInitialURL().then(data => {
console.log(data);
});
}当我启动我的应用程序时,data被正确地设置为null。
然后,用户通过Google Chrome登录,该浏览器通过
Linking.open('https://...);当用户被重定向回我的应用程序时,我可以看到data已经被填充。这一切都很好。
然而,当我被重定向回来时,我看到了重复的组件。这是来自React Native Debugger的屏幕截图。我有<AppContainer root=1..>和<AppContainer root=11..>

由于这种重复,我的应用程序调用了componentDidMount()两次,Linking.getInitialURL()被调用了多次。
此外,如果我通过开发人员菜单刷新应用程序,从Linking.getInitialURL的promise返回的data仍然填充,而它应该是null。
发布于 2017-08-18 17:54:34
这个问题的解决方案是将android:launchMode="singleTask"添加到我的.MainActivity活动中。
在this Github线程上找到解决方案。
https://stackoverflow.com/questions/45752822
复制相似问题