Browse Source

Docs: renamed input's state to `message`

Readers might feel confused with the actual input's `value` attribute.
main
Julen Ruiz Aizpuru 11 years ago
parent
commit
9da4c206dc
  1. 22
      docs/09.2-form-input-binding-sugar.md

22
docs/09.2-form-input-binding-sugar.md

@ -33,14 +33,14 @@ Here's a simple form example without using `ReactLink`:
var NoLink = React.createClass({ var NoLink = React.createClass({
getInitialState: function() { getInitialState: function() {
return {value: 'Hello!'}; return {message: 'Hello!'};
}, },
handleChange: function(event) { handleChange: function(event) {
this.setState({value: event.target.value}); this.setState({message: event.target.value});
}, },
render: function() { render: function() {
var value = this.state.value; var message = this.state.message;
return <input type="text" value={value} onChange={this.handleChange} />; return <input type="text" value={message} onChange={this.handleChange} />;
} }
}); });
``` ```
@ -53,10 +53,10 @@ This works really well and it's very clear how data is flowing, however with a l
var WithLink = React.createClass({ var WithLink = React.createClass({
mixins: [React.addons.LinkedStateMixin], mixins: [React.addons.LinkedStateMixin],
getInitialState: function() { getInitialState: function() {
return {value: 'Hello!'}; return {message: 'Hello!'};
}, },
render: function() { render: function() {
return <input type="text" valueLink={this.linkState('value')} />; return <input type="text" valueLink={this.linkState('message')} />;
} }
}); });
``` ```
@ -82,14 +82,14 @@ There are two sides to `ReactLink`: the place where you create the `ReactLink` i
var WithoutMixin = React.createClass({ var WithoutMixin = React.createClass({
getInitialState: function() { getInitialState: function() {
return {value: 'Hello!'}; return {message: 'Hello!'};
}, },
handleChange: function(newValue) { handleChange: function(newValue) {
this.setState({value: newValue}); this.setState({message: newValue});
}, },
render: function() { render: function() {
var valueLink = { var valueLink = {
value: this.state.value, value: this.state.message,
requestChange: this.handleChange requestChange: this.handleChange
}; };
return <input type="text" valueLink={valueLink} />; return <input type="text" valueLink={valueLink} />;
@ -107,10 +107,10 @@ As you can see, `ReactLink` objects are very simple objects that just have a `va
var WithoutLink = React.createClass({ var WithoutLink = React.createClass({
mixins: [React.addons.LinkedStateMixin], mixins: [React.addons.LinkedStateMixin],
getInitialState: function() { getInitialState: function() {
return {value: 'Hello!'}; return {message: 'Hello!'};
}, },
render: function() { render: function() {
var valueLink = this.linkState('value'); var valueLink = this.linkState('message');
var handleChange = function(e) { var handleChange = function(e) {
valueLink.requestChange(e.target.value); valueLink.requestChange(e.target.value);
}; };

Loading…
Cancel
Save