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

217
Views
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 answers
Answer question

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 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!