[Checkbox] Pass the native event as second argument of onCheckedChange
See original GitHub issueHello all,
Feature request
onCheckedChange
used to pass the native event
, and is now passing a custom state for convenience (and the “indeterminate” state).
In our case we rely on react-hook-form to handle our forms lifecycle and validation, and it’s using the native events by default in order to synchronise the inputs values with the form’s global state : https://react-hook-form.com/api/useform/register
Not having access to the native event anymore will force us to pass a custom onChange
functions to our checkboxes implemented with radix :
// Checkbox is our own implementation over Radix primitives
// setValue is also from react-hook-form
<Checkbox {...register("is_happy")} onChange={(checked) => { setValue("is_happy", checked); }} />
Overview
Passing the native event as a second argument of onCheckedChange
would be helpful for interoperability.
Examples in other libraries
Who does this impact? Who is this for?
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:10 (1 by maintainers)
Top Results From Across the Web
How To Use React Checkbox onChange Feature (with Code ...
In this tutorial, we'll learn how to utilize React Checkboxes onChange event handler to call functions without explicitly pressing submit.
Read more >Assigning a value (or any other parameter) to asp:checkbox
Right now i have all of them tied to one event handler that fires on CheckedChanged, then i cast the sender to Checkbox...
Read more >Passing Value to an OnCheckedChanged Event Handler of ...
Passing Value to an OnCheckedChanged Event Handler of asp.net Checkbox Control ... As the purpose is to focus on checkbox and passing value....
Read more >Checkboxes - Android Developers
When the user selects a checkbox, the CheckBox object receives an on-click event. To define the click event handler for a checkbox, add...
Read more >Native Events in Blazor CheckBox Component | Syncfusion
The onchange attribute is used to bind the onchange event for Checkbox. Here, we have explained about the sample code snippets of Checkbox....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@gpeto91 check out their Controller component.
Here’s a working example https://codesandbox.io/s/weathered-worker-huynj?file=/src/App.js
Im using the useController hook to gain access to the API of react-hook-form. The API is a little cleaner than using the
<Controller/>
HOC, imo.For ex: