'use strict';
import React from 'react/addons';
import reactMixin from 'react-mixin';
let { LinkedStateMixin } = React.addons;
class App extends React.Component {
constructor() {
super();
this.state = {
name: ''
}
}
render() {
<input type='text' valueLink={this.linkState('name')} />
}
}
reactMixin.onClass(App, LinkedStateMixin);
因为我的表单很多很复杂,用了之后直接减少了100多行代码。
建议大家在操作大量的表单时考虑使用。