Olli
Olli

Reputation: 532

Passing down value

I'm trying to pass this.props.item down so I can perform some actions with it however I've been unable to do so, it's giving me the error: Invalid left-hand side in arrow function parameters. It's running through an array so it actually has the value

<TouchableOpacity onPress={(this.props.item) => {
  //Do something with value here
 }}
>

I also tried this way unluckily

<TouchableOpacity onPress={this.props.item => {
  //Do something with value here
 }}
>

What's the correct way to write this please?

Upvotes: 0

Views: 39

Answers (1)

Mos&#232; Raguzzini
Mos&#232; Raguzzini

Reputation: 15821

May be you are looking for something like this

<TouchableOpacity onPress={() => {
  console.log(this.props.item)
 }}
>

Upvotes: 1

Related Questions