fakiolinho / react-loading

React component for loading animations

Home Page:https://codesandbox.io/s/mqx0ql55qp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Warning - setState({...}) on unmounted component

crobinson42 opened this issue · comments

Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component.

Here's my code:

componentDidMount() {
 this.fetchUsers(); // will make request to server and setState
}

render(){
    if (this.state.users.length === 0) {
      return ( <Loading type='balls' color='#e3e3e3' />);
    }
    else {
      return (
       {this.userList()}
      );
    }
}

When I remove the console warning goes away which leads me to point the finger at react-loading.

@cezary Any thoughts on this issue? I was thinking of giving a PR a try to fix this.

It was an issue with the delay and the component being unmounted before the delay, sorry for the long wait.