PRANAV
PRANAV

Reputation: 1111

How to combine two arrow function?

how to combine below two functions , which I need to use in single element. Please help

onClick={() => setSelectedItem("List A")}
onClick={(e) => e.stopPropagation()}

e.g <a onClick={function1, funtion2} 

Upvotes: 0

Views: 317

Answers (3)

Atul More
Atul More

Reputation: 26

onClick = {(e) => { setSelectedItem("List A"); e.stopPropagation() }}

Upvotes: 1

Dropout
Dropout

Reputation: 13876

Just put them into a single function

onClick = {(e) => {
    e.stopPropagation();
    setSelectedItem("List A");
}}

Upvotes: 1

Mechanic
Mechanic

Reputation: 5390

invoke them all in one function body

<a onClick={(e) => {
  e.stopPropagation();
  setSelectedItem("List A")
}} >

Upvotes: 1

Related Questions