diff --git a/docs/forms.md b/docs/forms.md index fdab54095..51cec75ad 100644 --- a/docs/forms.md +++ b/docs/forms.md @@ -13,8 +13,10 @@ HTML form elements work a little bit differently from other DOM elements in Reac ```html
``` @@ -29,7 +31,7 @@ We can combine the two by making the React state be the "single source of truth" For example, if we want to make the previous example log the name when it is submitted, we can write the form as a controlled component: -```javascript{4,10-12,23} +```javascript{4,10-12,24} class NameForm extends React.Component { constructor(props) { super(props); @@ -51,8 +53,10 @@ class NameForm extends React.Component { render() { return ( ); @@ -60,7 +64,7 @@ class NameForm extends React.Component { } ``` -[Try it on CodePen.](https://codepen.io/lacker/pen/oYNzxY?editors=0010) +[Try it on CodePen.](https://codepen.io/gaearon/pen/VmmPgp?editors=0010) 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. @@ -84,7 +88,7 @@ In HTML, a `