flimflam57
flimflam57

Reputation: 1334

Multiple props inside click event

I know I can put multiple functions inside an event handler like this:

  onClick={() => {function1(); function2()}}

If I need two props inside an event handler, can it be done the same way?

  onClick={() => {this.props.prop1(); this.props.prop2()}}

Or should they be combined into a single prop prior?

Upvotes: 1

Views: 75

Answers (1)

Gautam Naik
Gautam Naik

Reputation: 9358

Merging them will increase readability

combinedFunction(){ 
     this.props.prop1(); 
     this.props.prop2()
    }

onClick={this.combinedFunction}

Upvotes: 1

Related Questions