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

126
Vistas
Handling touch in React Native with time

I am working on an onPress event in React Native. I have added two different actions onPress, onLongPress. I have two different functions associated with each of them. Now i have also added delayLongPress={250} and it's working with onLongPress. But when i try to call the onLongPress, it calls the onPress too. I don't want that to happen. I want to call the onpress when it's pressed just once and onLongPress when it's pressed for 250ms at least. How can i seperate those function calls.

Here's what i have right now:

const onLongPress = () =>{
    console.log('Pressed long')
}
const onChange = () =>{
    console.log('Pressed')
}

return(
<Container
     onPress={onChange}
     onLongPress={onLongPress}
     delayLongPress={250}
>
</Container>
)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try to wrap it with the TouchableHighlight.

export default function App() {
  const onLongPress = () => {
    console.log('Pressed long');
  };
  const onChange = () => {
    console.log('Pressed');
  };
  return (
    <TouchableHighlight
      onPress={onChange}
      onLongPress={onLongPress}
      delayLongPress={250}
    >
      <Text>Press</Text> // Your child components goes here
    </TouchableHighlight>
  );
}

See the snack 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