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

263
Vistas
Why Linking.openURL fires automaticaly without TouchableOpacity?

i have a problem with function in React Native. I checking if the String is e-mail, text or phone and returns appropriate object, e.g Linking.openURL(mailto:${phone}).

But function automatically fires the URL and forwarding me to Phone Application, what im doing wrong?

A function to check value in a String

function checkResult(result){
  let emailChecker = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  if( !( emailChecker.test(result))){
    return Linking.openURL(`mailto:${result}`)
  }

  if(isNaN(result)){
    return Linking.openURL(`tel:${result}`)
  }
}

My touchableOpacity

<TouchableOpacity
        onPress={checkResult(result)}
        >
        <Text
          style={{
            color: 'blue',
            fontSize: 20,
            marginTop: 10,
            marginBottom: 40,
          }}
        >
          {result}
        </Text>
        </TouchableOpacity>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

onPress={checkResult(result)} this will result in calling the function checkResult when you pass it to the component, so the function will execute on render.

Update your onPress callback to () => checkResult(result).

<TouchableOpacity
  onPress={() => checkResult(result)} 
>
  <Text
      style={{
      color: 'blue',
      fontSize: 20,
      marginTop: 10,
      marginBottom: 40,
    }}
    >
      {result}
    </Text>
</TouchableOpacity>

for more details on passing function to component - here

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