aharon vishinsky
aharon vishinsky

Reputation: 229

React native getInitialURL not nullify after use

After using Linking.getInitialURL() the URL stay there.

I am using react-native-router-flux to navigate.

when users log out I run

   import { NativeModules } from 'react-native';
    NativeModules.DevSettings.reload()

What happens is the react-navigation do Linking.getInitialURL() and if there any result so it navigates automatically to the page.

how to reset Linking.getInitialURL() after use ? happens only on android

Upvotes: 1

Views: 1040

Answers (1)

satya164
satya164

Reputation: 10145

React Navigation 5 provides an option to specify a custom getInitialURL method which you can use:

<NavigationContainer
  linking={{
    // ... linking config
    getInitialURL() {
      return YourCustomModule.getInitialURL();
    },
  }}
>
  {/* content */}
</NavigationContainer>

https://reactnavigation.org/docs/navigation-container/#linkinggetinitialurl

For the implementation, since you're reloading the whole JS, the code cannot be in JS as the state is lost on reload. You'll need to write a custom native module where you can clear the initial URL when reloading.

Upvotes: -1

Related Questions