-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
Only observe nodes when the 'onLayout' prop is specified on the element. Fixes performance regression for browsers that rely on MutationObserver-based shim for ResizeObserver. Fix #1128 Close #1129
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,9 @@ const applyLayout = Component => { | |
function componentDidMount() { | ||
this._layoutState = emptyObject; | ||
this._isMounted = true; | ||
observe(this); | ||
if (this.props.onLayout) { | ||
observe(this); | ||
} | ||
} | ||
); | ||
|
||
|
@@ -116,7 +118,9 @@ const applyLayout = Component => { | |
componentWillUnmount, | ||
function componentWillUnmount() { | ||
this._isMounted = false; | ||
unobserve(this); | ||
if (this.props.onLayout) { | ||
unobserve(this); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bloodyowl
Contributor
|
||
} | ||
} | ||
); | ||
|
||
|
would't the following case cause a memory leak?