页面会报告已经警告
Warning: `valueLink` prop on `input` is deprecated; set `value` and `onChange` instead.
Note: LinkedStateMixin is deprecated as of React v15. The recommendation is to explicitly set the value and change handler,instead of using LinkedStateMixin.
参考文档:https://facebook.github.io/react/docs/two-way-binding-helpers.html
DEMO 代码
npm install react-addons-linked-state-mixin –save
import React from 'react';
import Reflux from 'reflux'
var ReactDOM = require('react-dom');
import LinkedStateMixin from 'react-addons-linked-state-mixin'
var HelloWorld = React.createClass({
mixins: [LinkedStateMixin],getInitialState: function() {
return {message: 'Hello!'};
},render: function () {
return <div>
{this.state.message}
<input type="text" valueLink={this.linkState('message')}/>
</div>
}
})
ReactDOM.render(
<HelloWorld />,document.getElementById('J_contentContainer'))