Skip to content

Commit

Permalink
onChange() does not work properly with <input type="number">, see fac…
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrotoff committed Oct 6, 2017
1 parent bb7d249 commit 0ec46d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,4 @@ If you support older browsers (<IE11) you will need a global polyfill such as [c
## Notes

- A [`readonly`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-readonly) or `disabled` input won't trigger any HTML5 form constraint like [`required`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-required).
- With `<input type="number">` it's better to use `onInput` instead of `onChange`, see https://github.com/facebook/react/issues/11142
3 changes: 2 additions & 1 deletion examples/HttpStatusCode/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ class Form extends React.Component<Props, State> {
onSubmit={this.handleSubmit} noValidate>
<div>
<label htmlFor="http-status-code">HTTP Status code (enter 200, 404, 500, 503)</label>
{/* onChange() does not work properly with <input type="number">, see https://github.com/facebook/react/issues/11142 */}
<input type="number" name="httpStatusCode" id="http-status-code"
value={this.state.httpStatusCode} onChange={this.handleChange}
value={this.state.httpStatusCode} onInput={this.handleChange}
min={100} max={599} required />
<FieldFeedbacks for="httpStatusCode">
<FieldFeedback when="*" />
Expand Down

0 comments on commit 0ec46d5

Please sign in to comment.