Skip to content

Commit 8dbf114

Browse files
RSNarafacebook-github-bot
authored andcommitted
Refactor: ReactInstance: Store JsErrorHandler inside a shared_ptr
Summary: Just makes it easier to pass around JsErrorHandler. We'll need this in D55547897, when we start storing the "has fataled" boolean inside the JsErrorHandler. Changelog: [internal] Reviewed By: cipolleschi Differential Revision: D55547898
1 parent f161d28 commit 8dbf114

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ ReactInstance::ReactInstance(
3636
: runtime_(std::move(runtime)),
3737
jsMessageQueueThread_(jsMessageQueueThread),
3838
timerManager_(std::move(timerManager)),
39-
jsErrorHandler_(std::move(jsErrorHandlingFunc)),
39+
jsErrorHandler_(
40+
std::make_shared<JsErrorHandler>(std::move(jsErrorHandlingFunc))),
4041
hasFatalJsError_(std::make_shared<bool>(false)),
4142
parentInspectorTarget_(parentInspectorTarget) {
4243
RuntimeExecutor runtimeExecutor = [weakRuntime = std::weak_ptr(runtime_),
@@ -224,7 +225,7 @@ void ReactInstance::loadScript(
224225
} catch (jsi::JSError& error) {
225226
// Handle uncaught JS errors during loading JS bundle
226227
*hasFatalJsError_ = true;
227-
this->jsErrorHandler_.handleJsError(error, true);
228+
jsErrorHandler_->handleJsError(error, true);
228229
}
229230
});
230231
}

packages/react-native/ReactCommon/react/runtime/ReactInstance.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class ReactInstance final : private jsinspector_modern::InstanceTargetDelegate {
8080
std::shared_ptr<TimerManager> timerManager_;
8181
std::unordered_map<std::string, std::shared_ptr<CallableModule>> modules_;
8282
std::shared_ptr<RuntimeScheduler> runtimeScheduler_;
83-
JsErrorHandler jsErrorHandler_;
83+
std::shared_ptr<JsErrorHandler> jsErrorHandler_;
8484

8585
// Whether there are errors caught during bundle loading
8686
std::shared_ptr<bool> hasFatalJsError_;

0 commit comments

Comments
 (0)