Question: I have a button with an onPress event in React Native.

I want to get the entire class this

Here's my code:

```
        <TouchableOpacity onPress={this.onFBLoginButtonPress}>
          <View>
            <Text>Sign In with Facebook</Text>
            <Image source={FBImg} />
          </View>
        </TouchableOpacity>

```

I have tried onPress={() => this.onFBLoginButtonPress}

But this causes the button to not actually process.

How do I pass the entire class's this, without breaking the button?

Answer: 
Not sure if this is the best way, but this seems to work:

```
<TouchableOpacity self={this} onPress={this.onFBLoginButtonPress}>

```
Ther are two ways to call/invoke `methods/functions` in react native.

> 
> Way-1: Binding the function in constructor.
> 
> 
> 

```
export default class yourClassName extends React.Component {
  constructor(props) {
    super(props);
    this.onFBLoginButtonPress = this.onFBLoginButtonPress.bind(this); //->This will bind your function to the class and have access of this.
  }

  onFBLoginButtonPress() {
    alert('I am Called');
  }
  render() {
    return (
      <TouchableOpacity onPress={this.onFBLoginButtonPress}>
        <View>
          <Text>Sign In with Facebook</Text>
          <Image source={FBImg} />
        </View>
      </TouchableOpacity>
    )
  }
}

```

> 
> Way-2 : Using fat arrow function introduced in ECMA-6
> 
> 
> 

```
export default class yourClassName extends React.Component {

  onFBLoginButtonPress = () => {
    alert('I am Called');
  }

  render() {
    return (
      <TouchableOpacity onPress={() => this.onFBLoginButtonPress()}>
        <View>
          <Text>Sign In with Facebook</Text>
          <Image source={FBImg} />
        </View>
      </TouchableOpacity>
    )
  }
}

```

Try this and this will resolve the issue.