Skip to content

Commit

Permalink
[fix] Memory leak in applyLayout registry
Browse files Browse the repository at this point in the history
Remove component instances from the layout registry when umounting views
that are using ResizeObserver.

Fix #1133
Close #1134
  • Loading branch information
comp615 authored and necolas committed Oct 12, 2018
1 parent bfaeae9 commit ad188a7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/react-native-web/src/modules/applyLayout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,15 @@ const observe = instance => {
};

const unobserve = instance => {
delete registry[instance._layoutId];
if (resizeObserver) {
const node = findNodeHandle(instance);
if (node) {
delete registry[node._layoutId];
delete node._layoutId;
resizeObserver.unobserve(node);
}
} else {
delete registry[instance._layoutId];
delete instance._layoutId;
}
};
Expand Down

0 comments on commit ad188a7

Please sign in to comment.