Skip to content

Commit d902158

Browse files
c-milesnecolas
authored andcommitted
Fix memory leak in AnimatedProps constructor
Removes __attach() call from AnimatedProps constructor that caused duplicate child additions when combined with lifecycle hook. The constructor was calling __attach(), then useLayoutEffect in useAnimatedProps called it again on the same instance, causing each AnimatedProps to be added as a child twice to its parent nodes. This led to unbounded memory growth in applications with frequent re-renders. This change aligns with React Native core implementation, which does not call __attach() in the AnimatedProps constructor
1 parent ac73f24 commit d902158

File tree

1 file changed

+0
-1
lines changed
  • packages/react-native-web/src/vendor/react-native/Animated/nodes

1 file changed

+0
-1
lines changed

packages/react-native-web/src/vendor/react-native/Animated/nodes/AnimatedProps.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class AnimatedProps extends AnimatedNode {
3232
}
3333
this._props = props;
3434
this._callback = callback;
35-
this.__attach();
3635
}
3736

3837
__getValue(): Object {

0 commit comments

Comments
 (0)