Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
Hot to wait for Linking to finish in React Native?

I am creating a function that uses the React Native Linking library with the built-in URL scheme for opening the phone app. My idea is to wait until the user either makes the call or clicks on cancel, and then navigate somewhere else.

Here's the code:

const openPhoneCall = async () => {
    await Linking.openURL(`tel:${phoneNum}`);
    navigateToDashboard();
};

My issue is that the phone modal opens and immediately navigates to the dashboard, instead of waiting on either making the call or clicking on cancel and then navigating.

Any way to solve this?

Thank you

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I think you can use an app state listener on this screen particularly and call navigateToDashboard whenever the user got a blur event

example:

import React, {useEffect} from 'react';
import {AppState} from 'react-native';
...

function App() {
  ...
  useEffect(() => {
    const listener = AppState.addEventListener('blur', state => {
      navigateToDashboard();
    });

    return listener.remove;
  }, []);
  ...
}

export default App;
about 4 years ago · Juan Pablo Isaza Report

0

I managed to find a way to solve this by using AppState.

const appState = useRef(AppState.currentState);
useEffect(() => {
    const subscription = AppState.addEventListener("change", (nextAppState) => {
      if (
        appState.current.match(/inactive|background/) &&
        nextAppState === "active"
      ) {
        navigateToDashboard();
      }
      appState.current = nextAppState;
    });

    return () => {
      subscription.remove();
    };
 }, []);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!