Skip to content

setState() on an unmounted component warning #5

Description

@flash1293

The call to setState in the onload-handler should be guarded by isMounted. My app was adding some images and removing them due to ajax-updates before the image could be loaded. Thus the call inside onload was trying to set the state of an unmounted component.

img.onload = function() {
      if(self.isMounted()) {
        self.setState({loaded: true})
      }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions