Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how can i pass event and parameter onHandle change

    const onCheckedValue = (notification, event) => {
        console.log('notification', notification);
        console.log('event', event);

        
    };

// I want to pass the event and another parameter to the above function how can I achieve that?

<Checkbox
 checked={notification.is_selected}
 onChange={onCheckedValue(notification,event)}
 value={notification}
/>
                                               

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The easiest way would be to use an anonymous function:

<Checkbox onChange={(event)=>onCheckedValue(notification, event)} />

Your version doesn’t work because you call the function onCheckedValue during render, which means that the you’re setting the return value of oncheckedValue to the prop onChange instead of the function itself.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading