* 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
@ -34,7 +34,7 @@ To update the value in response to user input, you would use the `onChange` even
class Form extends React.Component {
constructor(props) {
super(props);
this.state = {value: ""};
this.state = {value: ''};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
@ -44,7 +44,7 @@ class Form extends React.Component {
}
handleSubmit(event) {
alert("Text field value is: '" + this.state.value + "'");
alert('Text field value is: ' + this.state.value);
}
render() {
@ -99,7 +99,7 @@ If you wanted to listen to updates to the value, you could use the `onChange` ev
class Form extends React.Component {
constructor(props) {
super(props);
this.state = {value: ""};
this.state = {value: ''};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
@ -109,7 +109,7 @@ class Form extends React.Component {
}
handleSubmit(event) {
alert("Text field value is: '" + this.state.value + "'");
alert('Text field value is: ' + this.state.value);
}
render() {
@ -161,7 +161,7 @@ Like all DOM events, the `onChange` prop is supported on all native components a
> Note:
>
> 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.
> 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.
## Advanced Topics
@ -204,9 +204,9 @@ If you *do* decide to use children, they will behave like `defaultValue`.
### Why Select Value?
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:
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:
```javascript
```javascript{1}
<selectvalue="B">
<optionvalue="A">Apple</option>
<optionvalue="B">Banana</option>
@ -233,7 +233,7 @@ For instance, if you want to imperatively submit a form, one approach would be t
class Form extends React.Component {
constructor(props) {
super(props);
this.state = {value: ""};
this.state = {value: ''};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
@ -242,14 +242,18 @@ class Form extends React.Component {
}
handleSubmit(event) {
alert("Text field value is: '" + this.state.value + "'");
alert('Text field value is: ' + this.state.value);