1

Sorry for the long winded title.

Here's my componentDidMount() function

componentDidMount() {
  Linking.getInitialURL().then(data => {
    console.log(data);
  });
}

When I boot up my app, data is rightfully set to null.

A User then logs in via Google Chrome which is opened via

Linking.open('https://...);

When the User gets redirected back to my app, I can see that data has been populated. This is all well and good.

However, when I am redirected back, I see duplicate components. Here's a screenshot from the React Native Debugger. I have <AppContainer root=1..> and <AppContainer root=11..>

enter image description here

Because of this duplication, my app calls componentDidMount() twice and Linking.getInitialURL() is called multiple times.

Furthermore, if I refresh the app via the developer menu, the data returned from Linking.getInitialURL's promise is still populated when it should be null.

Dan
  • 8,041
  • 8
  • 41
  • 72

1 Answers1

3

The solution to this problem was to add android:launchMode="singleTask" to my .MainActivity activity.

Solution found on this Github thread.

Dan
  • 8,041
  • 8
  • 41
  • 72