Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda