Handling Firebase passwordless email sign in with React Navigation

I am trying to handle Firebase passwordless email sign in with React Navigation under Expo. Firebase creates a deep link that opens the app with "exp://XXX.XXX.XX/--/auth?apikey=xxxxxx..." This link can be then parsed and checked to see if it's a sign in link with firebase.auth().isSignInWithEmailLink(url);

I read a ton of documentation. I may be wrong, but I believe I need to listen to the incoming link with Linking.getInitialURL() if the app is closed, and Linking.addEventListener if it's open.

I integrated this logic into a useEffect and I'm getting a pretty messy outcome. The incoming URL is indeed parsed as it should be. I have the event listener do the same and I clean it up in the useEffect. However, my useEffect is called whenever the user object changes, which means it runs several times and since the URL doesn't change, it tries to reauthenticate again and again.

Now I see this example on React Navigation: https://reactnavigation.org/docs/deep-linking/#third-party-integrations where it looks like they handle the deeplinks listener inside the linking configuration. The don't use any of it inside a useEffect.

Could someone who knows this stuff well please share an example code with explanation of where to place it when using Expo and react Navigation 5 listening for firebase.auth().isSignInWithEmailLink(url);?