@samitouri / QOS-React-2 / commits / 5bf8cda58f

document checkbox using click handlers for change events

I hit an issue related to this earlier today. Feels like a short paragraph warning of potential issues would be of benefit. Discussed with @zpao on IRC, agreed to make PR. For more info: * https://github.com/facebook/react/issues/3005#issuecomment-72513965 * https://github.com/facebook/react/blob/c7e4f55eb061b578497ed316d3e9e0dfa7026f46/src/browser/eventPlugins/ChangeEventPlugin.js#L287

Nick Williams committed Feb 5, 2015 at 22:32 UTC 5bf8cda58f81e940d7f2eafb18bd87c4f1244882
1 file changed +4
docs/docs/07-forms.md
+4
@@ -64,6 +64,10 @@ In this example, we are simply accepting the newest value provided by the user a
64
65 This would accept user input but truncate the value to the first 140 characters.
66
67 +### Potential Issues With Checkboxes and Radio Buttons
68 +
69 +Be aware that, in an attempt to normalise change handling for checkbox and radio inputs, React uses a `click` event in place of a `change` event. For the most part this behaves as expected, except when calling `preventDefault` in a `change` handler. `preventDefault` stops the browser from visually updating the input, even if `checked` gets toggled. This can be worked around either by removing the call to `preventDefault`, or putting the toggle of `checked` in a `setTimeout`.
70 +
71
72 ## Uncontrolled Components
73