How do I use radio buttons in React?

前端 未结 4 1862
别那么骄傲
别那么骄傲 2021-02-13 22:36

I\'m making a form, and I was in need of a radio input. How do I get the checked radio input in a onSubmit-function, what is the correct way?

This is my code, I myRadioI

4条回答
  •  生来不讨喜
    2021-02-13 22:47

    You shouldn't use refs to get access to DOM nodes and inspect their value. Instead you should link the inputs value to a property on the component state.

    Here are some examples of how to do it: https://facebook.github.io/react/docs/two-way-binding-helpers.html

提交回复
热议问题