Home > database >  How to do more than 1 action with onClick handler?
How to do more than 1 action with onClick handler?

Time:10-12

I have a button with action from props:

<div className={classes['Menu__nav-item']}
     onClick={props.InformationScroll}
>
    Info
</div>

but I want to execute one more action, how to properly do it ?

  <div className={classes['Menu__nav-item']}
         onClick={props.InformationScroll; () => setFlag(!flag)} #pseudocode
    >
        Info
    </div>

CodePudding user response:

<div className={classes['Menu__nav-item']}
         onClick={() => {
props.InformationScroll()
setFlag(!flag)
}} #pseudocode
    >
        Info
    </div>

CodePudding user response:

Just write a separate function and send the relevant parameters with "onClick".

  • Related