Skip to content

Commit d55558e

Browse files
zhongwuzwfacebook-github-bot
authored andcommitted
Fix isBatchActive of RCTCxxBridge (#22785)
Summary: Seems we lost handler of `isBatchActive` from [RCTBatchedBridge a86171a](https://github.com/facebook/react-native/blob/a86171a48284c440226a79a26c6d6a4704d401e9/React/Base/RCTBatchedBridge.m) to [RCTCxxBridge 5bc7e39](b774820#diff-a2a67635fffd7b690d14dc17ae563a71). Changelog: ---------- [iOS] [fixed] - Fix isBatchActive of RCTCxxBridge Pull Request resolved: #22785 Reviewed By: mhorowitz Differential Revision: D13731897 Pulled By: cpojer fbshipit-source-id: 8d6b85bcea8fe8997a93b4e1ac8b8007422ca20e
1 parent be51dbc commit d55558e

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

React/CxxBridge/RCTCxxBridge.mm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ void onBatchComplete() override {
152152

153153
@implementation RCTCxxBridge
154154
{
155-
BOOL _wasBatchActive;
156155
BOOL _didInvalidate;
157156
BOOL _moduleRegistryCreated;
158157

@@ -1348,7 +1347,7 @@ - (void)stopProfiling:(void (^)(NSData *))callback
13481347

13491348
- (BOOL)isBatchActive
13501349
{
1351-
return _wasBatchActive;
1350+
return _reactInstance ? _reactInstance->isBatchActive() : NO;
13521351
}
13531352

13541353
- (void *)runtime

ReactCommon/cxxreact/Instance.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ void *Instance::getJavaScriptContext() {
149149
bool Instance::isInspectable() {
150150
return nativeToJsBridge_ ? nativeToJsBridge_->isInspectable() : false;
151151
}
152+
153+
bool Instance::isBatchActive() {
154+
return nativeToJsBridge_ ? nativeToJsBridge_->isBatchActive() : false;
155+
}
152156

153157
void Instance::callJSFunction(std::string &&module, std::string &&method,
154158
folly::dynamic &&params) {

ReactCommon/cxxreact/Instance.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class RN_EXPORT Instance {
5858
std::unique_ptr<const JSBigString> jsonValue);
5959
void *getJavaScriptContext();
6060
bool isInspectable();
61+
bool isBatchActive();
6162
void callJSFunction(std::string &&module, std::string &&method,
6263
folly::dynamic &&params);
6364
void callJSCallback(uint64_t callbackId, folly::dynamic &&params);

ReactCommon/cxxreact/NativeToJsBridge.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class JsToNativeBridge : public react::ExecutorDelegate {
3737
std::shared_ptr<ModuleRegistry> getModuleRegistry() override {
3838
return m_registry;
3939
}
40+
41+
bool isBatchActive() {
42+
return m_batchHadNativeModuleCalls;
43+
}
4044

4145
void callNativeModules(
4246
JSExecutor& executor, folly::dynamic&& calls, bool isEndOfBatch) override {
@@ -222,6 +226,10 @@ void* NativeToJsBridge::getJavaScriptContext() {
222226
bool NativeToJsBridge::isInspectable() {
223227
return m_executor->isInspectable();
224228
}
229+
230+
bool NativeToJsBridge::isBatchActive() {
231+
return m_delegate->isBatchActive();
232+
}
225233

226234
void NativeToJsBridge::handleMemoryPressure(int pressureLevel) {
227235
runOnExecutorQueue([=] (JSExecutor* executor) {

ReactCommon/cxxreact/NativeToJsBridge.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class NativeToJsBridge {
7575
void setGlobalVariable(std::string propName, std::unique_ptr<const JSBigString> jsonValue);
7676
void* getJavaScriptContext();
7777
bool isInspectable();
78+
bool isBatchActive();
7879

7980
void handleMemoryPressure(int pressureLevel);
8081

0 commit comments

Comments
 (0)