forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreact-native+0.73.4+011+optionalViewRecycling.patch
62 lines (57 loc) · 3.43 KB
/
react-native+0.73.4+011+optionalViewRecycling.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
diff --git a/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewClassDescriptor.h b/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewClassDescriptor.h
index b03a464..a2788a9 100644
--- a/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewClassDescriptor.h
+++ b/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewClassDescriptor.h
@@ -27,6 +27,11 @@ class RCTComponentViewClassDescriptor final {
*/
bool observesMountingTransactionWillMount{false};
bool observesMountingTransactionDidMount{false};
+
+ /*
+ * Whether the component can be recycled or not
+ */
+ bool shouldBeRecycled{true};
};
NS_ASSUME_NONNULL_END
diff --git a/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewDescriptor.h b/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewDescriptor.h
index 3ca65d1..fd1c4b9 100644
--- a/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewDescriptor.h
+++ b/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewDescriptor.h
@@ -29,6 +29,7 @@ class RCTComponentViewDescriptor final {
*/
bool observesMountingTransactionWillMount{false};
bool observesMountingTransactionDidMount{false};
+ bool shouldBeRecycled{true};
};
inline bool operator==(const RCTComponentViewDescriptor &lhs, const RCTComponentViewDescriptor &rhs)
diff --git a/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm b/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm
index 0b15d71..9bf4f2d 100644
--- a/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm
+++ b/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm
@@ -95,6 +95,8 @@ - (RCTComponentViewClassDescriptor)_componentViewClassDescriptorFromClass:(Class
(bool)class_respondsToSelector(viewClass, @selector(mountingTransactionWillMount:withSurfaceTelemetry:)),
.observesMountingTransactionDidMount =
(bool)class_respondsToSelector(viewClass, @selector(mountingTransactionDidMount:withSurfaceTelemetry:)),
+ .shouldBeRecycled =
+ [viewClass respondsToSelector:@selector(shouldBeRecycled)] ? (bool)[viewClass performSelector:@selector(shouldBeRecycled)] : true,
};
#pragma clang diagnostic pop
}
@@ -210,6 +212,7 @@ - (RCTComponentViewDescriptor)createComponentViewWithComponentHandle:(facebook::
.view = [viewClass new],
.observesMountingTransactionWillMount = componentViewClassDescriptor.observesMountingTransactionWillMount,
.observesMountingTransactionDidMount = componentViewClassDescriptor.observesMountingTransactionDidMount,
+ .shouldBeRecycled = componentViewClassDescriptor.shouldBeRecycled,
};
}
diff --git a/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewRegistry.mm b/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewRegistry.mm
index e78e8ae..74ebc31 100644
--- a/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewRegistry.mm
+++ b/node_modules/react-native/React/Fabric/Mounting/RCTComponentViewRegistry.mm
@@ -107,7 +107,7 @@ - (void)_enqueueComponentViewWithComponentHandle:(ComponentHandle)componentHandl
RCTAssertMainQueue();
auto &recycledViews = _recyclePool[componentHandle];
- if (recycledViews.size() > RCTComponentViewRegistryRecyclePoolMaxSize) {
+ if (recycledViews.size() > RCTComponentViewRegistryRecyclePoolMaxSize || !componentViewDescriptor.shouldBeRecycled) {
return;
}