Skip to content

Commit 81e5fc2

Browse files
committed
fix(android, app): fix hot-reload on react-native <= 0.73
super.invalidate() is an empty function in rn >= 0.74, so no need to call it going forward But on rn <= 0.73 it may not exist, and if it does it calls onCatalystInstanceDestroy which makes for a StackOverFlowException as we go recursive
1 parent 0103e12 commit 81e5fc2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

packages/app/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,13 @@ public final ExecutorService getTransactionalExecutor(String identifier) {
9292
return executorService.getTransactionalExecutor(identifier);
9393
}
9494

95-
96-
// This is no longer called as of react-native 0.74 and is only here for
97-
// compatibility with older versions. It delegates to thew new `invalidate`
95+
// On react-native 0.73 this is called, but simply calls `invalidate()`
96+
// https://github.com/facebook/react-native/blob/0.73-stable/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseJavaModule.java#L65-L72
97+
// This is no longer called ever for react-native >= 0.74 and is only here for
98+
// compatibility with older versions. We delegate to the new `invalidate`
9899
// method, which all modules should implement now
99100
// Remove this method when minimum supported react-native is 0.74
100-
/** @noinspection removal*/
101+
// @noinspection removal
101102
@SuppressWarnings({"deprecation", "removal"})
102103
@Deprecated
103104
public void onCatalystInstanceDestroy() {
@@ -107,11 +108,14 @@ public void onCatalystInstanceDestroy() {
107108
}
108109

109110
// This should have an @Override annotation but we cannot do
110-
// that until our minimum supported react-native version is 0.74, since the
111-
// method did not exist before then
111+
// that until our minimum supported react-native version is 0.74
112+
//
113+
// No need to call super.invalidate and in fact it is dangerous to do so:
114+
// - did not exist before react-native 0.73
115+
// - on 0.74 it calls onCatalystInstanceDestroy which would infinite loop here
116+
// - on 0.75+ it is empty - meant as sub-class hook only
112117
@CallSuper
113118
public void invalidate() {
114-
super.invalidate();
115119
executorService.shutdown();
116120
}
117121

0 commit comments

Comments
 (0)