fix loading (#8571)

This commit is contained in:
Wang Jun 2017-12-13 18:49:00 +08:00 committed by 偏右
parent 8f1fd4d68b
commit d825e27667

View File

@ -33,7 +33,7 @@ class UserRemoteSelect extends React.Component {
console.log('fetching user', value);
this.lastFetchId += 1;
const fetchId = this.lastFetchId;
this.setState({ fetching: true });
this.setState({ data: [], fetching: true });
fetch('https://randomuser.me/api/?results=5')
.then(response => response.json())
.then((body) => {
@ -43,9 +43,8 @@ class UserRemoteSelect extends React.Component {
const data = body.results.map(user => ({
text: `${user.name.first} ${user.name.last}`,
value: user.login.username,
fetching: false,
}));
this.setState({ data });
this.setState({ data, fetching: false });
});
}
handleChange = (value) => {