You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Reapplied fixes to updated docs from master
* Reapplied fixes to Forms, removed ES2016 function includes()
* Missing carriage return
* Adding back some line breaks
* Making requested changes.
* Making space changes
* Fixed typo and removed unnecessary hyphen.
* Reworded select, and highlighted line
* Fixed string styles
* Refactored <label> to use htmlFor
* Another refactor of <label>
* Removed name prop from radiobutton
Copy file name to clipboardExpand all lines: docs/docs/forms.md
+59-34Lines changed: 59 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ To update the value in response to user input, you would use the `onChange` even
34
34
class Form extends React.Component {
35
35
constructor(props) {
36
36
super(props);
37
-
this.state = {value: ""};
37
+
this.state = {value: ''};
38
38
this.handleChange = this.handleChange.bind(this);
39
39
this.handleSubmit = this.handleSubmit.bind(this);
40
40
}
@@ -44,7 +44,7 @@ class Form extends React.Component {
44
44
}
45
45
46
46
handleSubmit(event) {
47
-
alert("Text field value is: '" + this.state.value + "'");
47
+
alert('Text field value is: ' + this.state.value);
48
48
}
49
49
50
50
render() {
@@ -99,7 +99,7 @@ If you wanted to listen to updates to the value, you could use the `onChange` ev
99
99
class Form extends React.Component {
100
100
constructor(props) {
101
101
super(props);
102
-
this.state = {value: ""};
102
+
this.state = {value: ''};
103
103
this.handleChange = this.handleChange.bind(this);
104
104
this.handleSubmit = this.handleSubmit.bind(this);
105
105
}
@@ -109,7 +109,7 @@ class Form extends React.Component {
109
109
}
110
110
111
111
handleSubmit(event) {
112
-
alert("Text field value is: '" + this.state.value + "'");
112
+
alert('Text field value is: ' + this.state.value);
113
113
}
114
114
115
115
render() {
@@ -161,7 +161,7 @@ Like all DOM events, the `onChange` prop is supported on all native components a
161
161
162
162
> Note:
163
163
>
164
-
> For `<input>` and `<textarea>`, `onChange` should generally used instead of — the DOM's built-in [`oninput`](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/oninput) event handler.
164
+
> For `<input>` and `<textarea>`, `onChange` should generally be used instead of the DOM's built-in [`oninput`](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/oninput) event handler.
165
165
166
166
## Advanced Topics
167
167
@@ -204,9 +204,9 @@ If you *do* decide to use children, they will behave like `defaultValue`.
204
204
205
205
### Why Select Value?
206
206
207
-
The selected `<option>` in an HTML `<select>` is normally specified through that option's `selected` attribute. In React, in order to make components easier to manipulate, the following format is adopted instead:
207
+
The selected `<option>` in an HTML `<select>` is normally specified through that option's `selected` attribute. In React we assign the `select` component a specific value by passing a `value` prop:
208
208
209
-
```javascript
209
+
```javascript{1}
210
210
<select value="B">
211
211
<option value="A">Apple</option>
212
212
<option value="B">Banana</option>
@@ -233,7 +233,7 @@ For instance, if you want to imperatively submit a form, one approach would be t
233
233
classFormextendsReact.Component {
234
234
constructor(props) {
235
235
super(props);
236
-
this.state= {value:""};
236
+
this.state= {value:''};
237
237
this.handleChange=this.handleChange.bind(this);
238
238
this.handleSubmit=this.handleSubmit.bind(this);
239
239
}
@@ -242,14 +242,18 @@ class Form extends React.Component {
242
242
}
243
243
244
244
handleSubmit(event) {
245
-
alert("Text field value is: '"+this.state.value+"'");
0 commit comments