chenglou / react-radio-group

Better radio buttons.
MIT License
445 stars 75 forks source link

Make onChange handler optional #17

Closed deepakjois closed 8 years ago

deepakjois commented 9 years ago

If I do no specify an onChange handler, for e.g.

 <RadioGroup ref="deliverymethod" name="deliverymethod">
...
</RadioGroup>

I get an error:

Uncaught TypeError: Cannot read property 'bind' of undefined

Does the onChangeHandler need to be set. Can’t the React element maintain its own state, and update it when the value changes.

chenglou commented 9 years ago

If you don't provide onChange, you'll receive the warning that the handler's not set, because the library allows only controlled components for now. Maybe we should implement uncontrolled components, but that gets slightly messy.

briandamaged commented 8 years ago

I just created a PR that allows both the "onChange" and "selectedValue" properties to be optional. If neither property is specified, then React will treat the radio buttons as uncontrolled components.

nkbt commented 8 years ago

Fixed by #22