-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Open
Description
The "isMounted is an Antipattern" documentation article suggest avoiding memory leaks with makeCancelable
, but this doesn't actually solve the issue since the callback is still referenced. The garbage collector does not understand that setting hasCanceled_
means that resolve
will never be called, so it cannot release resolve
or the references contained within. Even if it could, reject
might also reference this
, so memory leaks could still exist. Instead, makeCancelable
should store the resolve
and reject
callbacks itself, and it should null them out on cancelation.
Another user pointed this issue out in facebook/react#5465 (comment)
jackkav, tsvetan-ganev, karpikpl, rszalski and Aprillion
Metadata
Metadata
Assignees
Labels
No labels