react-native-screens 4.19.0-nightly-20251211-12e4eacaa → 4.19.0-nightly-20251212-c9b84ff7a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,17 +7,19 @@ namespace facebook {
|
|
|
7
7
|
namespace react {
|
|
8
8
|
|
|
9
9
|
RNSScreenShadowNodeCommitHook::RNSScreenShadowNodeCommitHook(
|
|
10
|
-
std::shared_ptr<const ContextContainer> contextContainer)
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const std::shared_ptr<const ContextContainer> &contextContainer) {
|
|
11
|
+
if (auto uiManager = getUIManagerFromSharedContext(contextContainer)) {
|
|
12
|
+
uiManager->registerCommitHook(*this);
|
|
13
|
+
}
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
RNSScreenShadowNodeCommitHook::~RNSScreenShadowNodeCommitHook() noexcept {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
// We intentionally don't unregister the commit hook here.
|
|
18
|
+
// During hot reload, the FabricUIManagerBinding may already be destroyed
|
|
19
|
+
// when this destructor is called, causing a JNI crash when trying to
|
|
20
|
+
// access the binding. The UIManager will clean up hooks when it's destroyed
|
|
21
|
+
// In case the lifecycle of the commit hook should be shorter than
|
|
22
|
+
// that of the UIManager consider unregistering the hook manually.
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
RootShadowNode::Unshared RNSScreenShadowNodeCommitHook::shadowTreeWillCommit(
|
|
@@ -30,8 +32,8 @@ RootShadowNode::Unshared RNSScreenShadowNodeCommitHook::shadowTreeWillCommit(
|
|
|
30
32
|
auto newRootProps =
|
|
31
33
|
std::static_pointer_cast<const RootProps>(newRootShadowNode->getProps());
|
|
32
34
|
|
|
33
|
-
const bool wasHorizontal = isHorizontal_(*oldRootProps
|
|
34
|
-
const bool willBeHorizontal = isHorizontal_(*newRootProps
|
|
35
|
+
const bool wasHorizontal = isHorizontal_(*oldRootProps);
|
|
36
|
+
const bool willBeHorizontal = isHorizontal_(*newRootProps);
|
|
35
37
|
|
|
36
38
|
if (wasHorizontal != willBeHorizontal) {
|
|
37
39
|
return newRootShadowNodeWithScreenFrameSizesReset(newRootShadowNode);
|
|
@@ -87,14 +89,37 @@ void RNSScreenShadowNodeCommitHook::findScreenNodes(
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
|
|
92
|
+
/**
|
|
93
|
+
* This method might return nullptr. See its implementation for details.
|
|
94
|
+
*/
|
|
90
95
|
std::shared_ptr<UIManager>
|
|
91
96
|
RNSScreenShadowNodeCommitHook::getUIManagerFromSharedContext(
|
|
92
|
-
std::shared_ptr<const ContextContainer> sharedContext) {
|
|
97
|
+
const std::shared_ptr<const ContextContainer> &sharedContext) {
|
|
98
|
+
if (sharedContext == nullptr) {
|
|
99
|
+
return nullptr;
|
|
100
|
+
}
|
|
101
|
+
|
|
93
102
|
auto fabricUIManager =
|
|
94
103
|
sharedContext
|
|
95
104
|
->at<jni::alias_ref<facebook::react::JFabricUIManager::javaobject>>(
|
|
96
105
|
"FabricUIManager");
|
|
97
|
-
|
|
106
|
+
if (fabricUIManager == nullptr) {
|
|
107
|
+
return nullptr;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// This line might still crash in case the FabricUIManager.mBinding (Java
|
|
111
|
+
// class) is at this moment `null`.
|
|
112
|
+
auto *fabricUiManagerBinding = fabricUIManager->getBinding();
|
|
113
|
+
if (fabricUiManagerBinding == nullptr) {
|
|
114
|
+
return nullptr;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
auto scheduler = fabricUiManagerBinding->getScheduler();
|
|
118
|
+
if (scheduler == nullptr) {
|
|
119
|
+
return nullptr;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return scheduler->getUIManager();
|
|
98
123
|
}
|
|
99
124
|
|
|
100
125
|
} // namespace react
|
|
@@ -13,7 +13,8 @@ class RNSScreenComponentDescriptor;
|
|
|
13
13
|
|
|
14
14
|
class RNSScreenShadowNodeCommitHook : public UIManagerCommitHook {
|
|
15
15
|
public:
|
|
16
|
-
RNSScreenShadowNodeCommitHook(
|
|
16
|
+
RNSScreenShadowNodeCommitHook(
|
|
17
|
+
const std::shared_ptr<const ContextContainer> &);
|
|
17
18
|
|
|
18
19
|
virtual ~RNSScreenShadowNodeCommitHook() noexcept override;
|
|
19
20
|
|
|
@@ -28,8 +29,6 @@ class RNSScreenShadowNodeCommitHook : public UIManagerCommitHook {
|
|
|
28
29
|
const ShadowTreeCommitOptions & /*commitOptions*/) noexcept override;
|
|
29
30
|
|
|
30
31
|
private:
|
|
31
|
-
std::weak_ptr<const ContextContainer> contextContainer_;
|
|
32
|
-
|
|
33
32
|
static inline bool isHorizontal_(const RootProps &props) {
|
|
34
33
|
const auto &layoutConstraints = props.layoutConstraints;
|
|
35
34
|
const float width = layoutConstraints.maximumSize.width;
|
|
@@ -46,7 +45,7 @@ class RNSScreenShadowNodeCommitHook : public UIManagerCommitHook {
|
|
|
46
45
|
std::vector<const RNSScreenShadowNode *> &screenNodes);
|
|
47
46
|
|
|
48
47
|
static std::shared_ptr<UIManager> getUIManagerFromSharedContext(
|
|
49
|
-
std::shared_ptr<const ContextContainer> sharedContext);
|
|
48
|
+
const std::shared_ptr<const ContextContainer> &sharedContext);
|
|
50
49
|
};
|
|
51
50
|
|
|
52
51
|
} // namespace react
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-screens",
|
|
3
|
-
"version": "4.19.0-nightly-
|
|
3
|
+
"version": "4.19.0-nightly-20251212-c9b84ff7a",
|
|
4
4
|
"description": "Native navigation primitives for your React Native app.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"submodules": "git submodule update --init --recursive && (cd react-navigation && yarn && yarn build && cd ../)",
|