Skip to content

Commit 67df3c8

Browse files
zhongwuzwaleclarson
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](facebook/react-native@b774820#diff-a2a67635fffd7b690d14dc17ae563a71). Changelog: ---------- [iOS] [fixed] - Fix isBatchActive of RCTCxxBridge Pull Request resolved: facebook/react-native#22785 Reviewed By: mhorowitz Differential Revision: D13731897 Pulled By: cpojer fbshipit-source-id: 8d6b85bcea8fe8997a93b4e1ac8b8007422ca20e
1 parent 708f84e commit 67df3c8

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
@@ -156,7 +156,6 @@ void onBatchComplete() override {
156156

157157
@implementation RCTCxxBridge
158158
{
159-
BOOL _wasBatchActive;
160159
BOOL _didInvalidate;
161160
BOOL _moduleRegistryCreated;
162161

@@ -1306,7 +1305,7 @@ - (void)stopProfiling:(void (^)(NSData *))callback
13061305

13071306
- (BOOL)isBatchActive
13081307
{
1309-
return _wasBatchActive;
1308+
return _reactInstance ? _reactInstance->isBatchActive() : NO;
13101309
}
13111310

13121311
@end

ReactCommon/cxxreact/Instance.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ bool Instance::isInspectable() {
147147
return nativeToJsBridge_ ? nativeToJsBridge_->isInspectable() : false;
148148
}
149149

150+
bool Instance::isBatchActive() {
151+
return nativeToJsBridge_ ? nativeToJsBridge_->isBatchActive() : false;
152+
}
153+
150154
void Instance::callJSFunction(std::string &&module, std::string &&method,
151155
folly::dynamic &&params) {
152156
callback_->incrementPendingJSCalls();

ReactCommon/cxxreact/Instance.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class RN_EXPORT Instance {
5656
std::unique_ptr<const JSBigString> jsonValue);
5757
void *getJavaScriptContext();
5858
bool isInspectable();
59+
bool isBatchActive();
5960
void callJSFunction(std::string &&module, std::string &&method,
6061
folly::dynamic &&params);
6162
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
@@ -34,6 +34,10 @@ class JsToNativeBridge : public react::ExecutorDelegate {
3434
return m_registry;
3535
}
3636

37+
bool isBatchActive() {
38+
return m_batchHadNativeModuleCalls;
39+
}
40+
3741
void callNativeModules(
3842
JSExecutor& executor, folly::dynamic&& calls, bool isEndOfBatch) override {
3943

@@ -215,6 +219,10 @@ bool NativeToJsBridge::isInspectable() {
215219
return m_executor->isInspectable();
216220
}
217221

222+
bool NativeToJsBridge::isBatchActive() {
223+
return m_delegate->isBatchActive();
224+
}
225+
218226
#ifdef WITH_JSC_MEMORY_PRESSURE
219227
void NativeToJsBridge::handleMemoryPressure(int pressureLevel) {
220228
runOnExecutorQueue([=] (JSExecutor* executor) {

ReactCommon/cxxreact/NativeToJsBridge.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class NativeToJsBridge {
102102
void setGlobalVariable(std::string propName, std::unique_ptr<const JSBigString> jsonValue);
103103
void* getJavaScriptContext();
104104
bool isInspectable();
105+
bool isBatchActive();
105106

106107
#ifdef WITH_JSC_MEMORY_PRESSURE
107108
void handleMemoryPressure(int pressureLevel);

0 commit comments

Comments
 (0)