Your state is an array.
I have not seen anything in a React document in which a mention of a LinkedStateMixin connection can associate an input with an array index.
The following is likely to happen:
- Your initial condition
[42, 54] - If you change the item at index 0, LinkedStateMixin creates a new state {0: 43}
setState() , ( ), React JSON JS. :)
, array[index] object[key] .
, React , , , .
:
http://jsfiddle.net/f54Xr/3/
var Dummy = React.createClass({
mixins: [React.addons.LinkedStateMixin],
getInitialState: function() {
return {0: 42, 1: 54};
},
render: function() {
return <div>
{Object.keys(this.state).map(this.renderItem)}
<pre>{JSON.stringify(this.state, null, 2)}</pre>
</div>
},
renderItem: function(key) {
return <div>
<input type="number" valueLink={this.linkState(key)}/>
</div>
}
});
, LinkedStateMixin , :
React.js 2- : valueLink
, React = [42, 54], setState([undefined, 55]), , , = [42, 55], :)