import React from 'react'; import { Select } from 'antd'; const Yearselect = React.createClass({ getInitialState: function () { return { theOption: [] }; }, onChange(e) { this.props.handleyear(e); this.setState({ Year: e }); }, componentWillMount() { const Option = Select.Option; const d = new Date(); const thisYear = d.getFullYear(); this.state.thisYear = d.getFullYear(); for (let i = thisYear; i >= 1950; i--) { this.state.theOption.push() }; this.state.defYear = this.state.thisYear.toString(); }, componentWillUpdate(nextProps) { if (this.props.defValue != nextProps.defValue) { this.state.Year = nextProps.defValue; }; }, render() { return ( ) } }); export default Yearselect;