userOnline
userOnline

Reputation: 51

React Native not firing Console.log

I have this small sample react native code representing the main functionality of my original code. I am trying to console.log TouchbleOpacity onPress(). But the function is not firing anything on the console. Also, it does not console as soon as component mounts. Alert works fine, but this is not of concern. Here is my code:

import React, { Component } from 'react'
import { Text, View, TextInput, TouchableOpacity } from 'react-native'

export default class Terms extends Component {

  componentDidMount() {
    console.log('component mounted');
  }

  submitData = () => {
    console.log('button pressed');
    alert('hiiiii')
  }


  render() {
    return (
      <View>

        <TouchableOpacity onPress = {this.submitData} >
        <Text> textInComponent </Text>
        </TouchableOpacity>
      </View>
    )
  }
}

I tried different methods for function binding also, but not able to figure out the problem. It seemed to be working fine before but not now. Kindly help with the fix.

Upvotes: 5

Views: 6860

Answers (1)

Justmesam
Justmesam

Reputation: 91

Had the same issue I resulted to using console.warn. This appears as the YellowBox warning.
You can view your logs on the console also.
Here is an example screenshot.enter image description here

Upvotes: 3

Related Questions