Skip to content

Commit fa5e6e7

Browse files
authored
Remove misleading example in Forms (#2875)
* Remove misleading example in Forms * Update forms.md * Update forms.md
1 parent 7551fdf commit fa5e6e7

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

content/docs/forms.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,7 @@ class NameForm extends React.Component {
6868

6969
Since the `value` attribute is set on our form element, the displayed value will always be `this.state.value`, making the React state the source of truth. Since `handleChange` runs on every keystroke to update the React state, the displayed value will update as the user types.
7070

71-
With a controlled component, every state mutation will have an associated handler function. This makes it straightforward to modify or validate user input. For example, if we wanted to enforce that names are written with all uppercase letters, we could write `handleChange` as:
72-
73-
```javascript{2}
74-
handleChange(event) {
75-
this.setState({value: event.target.value.toUpperCase()});
76-
}
77-
```
71+
With a controlled component, the input's value is always driven by the React state. While this means you have to type a bit more code, you can now pass the value to other UI elements too, or reset it from other event handlers.
7872

7973
## The textarea Tag {#the-textarea-tag}
8074

0 commit comments

Comments
 (0)