import React, { Component } from 'react'; import './index.less'; import { Icon } from 'antd'; import { Main } from '../../stores/main'; export default class extends Component { constructor(props) { super(props); this.state = { quant: 50 }; this.time = 0; this.compute(props.value, 50); } componentWillReceiveProps(nextProps) { if (this.props.value !== nextProps.value) { this.compute(nextProps.value, this.state.quant || 50); } } compute(value, quant) { if (value === this.props.value && quant === this.state.quant) return; console.log(quant); this.time += 1; const number = this.time; this.setState({ quant }); Main.getScore(value, quant) .then(result => { if (number !== this.time) return; this.setState({ data: result }); }) .catch(() => { }); } render() { const { value, onChange } = this.props; const { data = {} } = this.state; return (