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

220
Vistas
React Native TouchableOpacity is auto clicked

I put console.log('Hello') to my button, to testing my button is work or not (actualy im using this button for navigation), but when i try to reload my app, my console show Hello. I didn't press my button yet, but when i try to press it my console didn't show hello. Sorry for my bad english

import React from 'react';
import {View, TouchableOpacity, Image} from 'react-native';
import s from './SFooter';
import {useNavigation} from '@react-navigation/native';

const Footer = () => {
  const navigation = useNavigation();
  let active = 0;
  return (
    <View style={s.footerWrapper}>
      <View style={s.iconsWrapper}>
        <View style={s.iconWrapper}>
          <TouchableOpacity
            onPress={(console.log('asda'), () => navigation.navigate('Home'))}>
            <Image
              style={s.icon}
              source={require('../../assets/icon/home.png')}
            />
            {active == 0 ? <View style={s.iconActive} /> : <View />}
          </TouchableOpacity>
        </View>
        <View style={s.iconWrapper}>
          <TouchableOpacity>
            <Image
              style={s.icon}
              source={require('../../assets/icon/book.png')}
            />
            {active == 1 ? <View style={s.iconActive} /> : <View />}
          </TouchableOpacity>
        </View>
        <View style={s.iconWrapper}>
          <TouchableOpacity>
            <Image
              style={s.icon}
              source={require('../../assets/icon/newspaper.png')}
            />
            {active == 2 ? <View style={s.iconActive} /> : <View />}
          </TouchableOpacity>
        </View>
        <View style={s.iconWrapper}>
          <TouchableOpacity>
            <Image
              style={s.icon}
              source={require('../../assets/icon/user.png')}
            />
            {active == 3 ? <View style={s.iconActive} /> : <View />}
          </TouchableOpacity>
        </View>
      </View>
    </View>
  );
};

export default Footer;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Please do check your code twice. You cannot call any function directly onPress. what i mean to say is following

Wrong:

   <TouchableOpacity
            onPress={(console.log('asda'), () => navigation.navigate('Home'))}

Correct

   <TouchableOpacity
            onPress={() => (console.log('asda'), () => navigation.navigate('Home'))}>
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