K
K
Komi7ar2020-12-21 18:40:36
JavaScript
Komi7ar, 2020-12-21 18:40:36

How to attach more than one function to an event handler?

Tell me how to make it so that two handlers were hung on the onClick event at once?

function FirstWindowItems({item, isActive, onClick}) {
    
    function handleClick(item){
        // e.preventDefault();
        console.log(item);
        onClick();
      }
    return(
        <div className={`row border ${isActive ? 'border-primary' : ''}`} onClick={handleClick(item), onClick}
        >
            {/* <div className = "window__item window__name">{item.id}</div> */}
            <div className = "col-md">{item.FIO}</div>
            <div className = "col-sm">{item.position}</div>
            <div className = "col-sm">{item.birthDay}</div>
            <div className = "col-sm">                {
                    item.sex ?
                        "М" : "Ж"                    
                }            
            </div>
            <div className = "col-sm">{
                    item.fired ?
                        "Уволен":"Работает"
            }
            </div>            
        </div>
    )
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WbICHA, 2020-12-21
@Komi7ar

Xs as far as Feng Shui is concerned, but as far as I remember, it can be done like this:

onClick={() => {
  handleClick(item);
  handleClick(item);
  handleClick(item);
  handleClick(item);
}}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question