/** * Created by W.X. on 2016/11/24. */ import * as React from "react"; import {autobind} from "core-decorators"; import TextField from 'material-ui/TextField'; export class TextFieldComponent extends React.Component { static propTypes = { value: React.PropTypes.string, onChange: React.PropTypes.func, }; constructor(props, context) { super(props, context); this.state = { value: props.value }; } componentWillReceiveProps(nextProps) { this.setState({ value: nextProps.value, }); } render() { const value = this.state.value; return ( ) } @autobind onChange(e) { const value = e.target.value; this.setState({value: value}); } @autobind onBlur(e) { const {onChange} = this.props; const value = e.target.value; onChange && onChange(value); } }