admin管理员组文章数量:1391951
What is the best practice for handling events on Radio Buttons and Check boxes in ReactJS? The documentation shows using "onClick" on the "Handling Events" documentation and it shows using "onChange" in the "Forms" documentation. onChange only fires one time on Radio Buttons, so I am currently using onClick for them. I assume this is a bug.
What is the best practice for handling events on Radio Buttons and Check boxes in ReactJS? The documentation shows using "onClick" on the "Handling Events" documentation and it shows using "onChange" in the "Forms" documentation. onChange only fires one time on Radio Buttons, so I am currently using onClick for them. I assume this is a bug.
Share Improve this question asked Aug 2, 2017 at 14:06 LambertLambert 2,4436 gold badges31 silver badges44 bronze badges 1- 1 Regarding radio buttons, check out Radio Input onChange only fires once? – Kevin Commented Aug 2, 2017 at 14:09
2 Answers
Reset to default 4Heyo, It's not a bug it is because in some cases you only want to know when it changes. For example, when you have an API that supports patch so you can send modifications on every change.
If your API only support submitting all at once the onClick is right for you!
Radio buttons respond to both onchange
and onclick
events in JavaScript. However, the onchange event may not work as you would expect it. The onchange
event is not triggered when turning a radio button on and off but only one or the other.
Most browsers trigger onchange
when the radio button is selected, but Internet Explorer prior to version 9 triggers onchange
when the radio button is deselected.
本文标签: javascriptonChange or onClick for Radio buttons and Check boxes in ReactJSStack Overflow
版权声明:本文标题:javascript - onChange or onClick for Radio buttons and Check boxes in ReactJS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744689731a2619919.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论