Skip to content

Commit 7e553ec

Browse files
authored
fix: Fix [super invalidate] being broken in react-native 0.82 or below (#1267)
1 parent 850e04c commit 7e553ec

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ ${createFileMetadataString(`${component}.mm`)}
6767
#import "${HybridTSpecSwift}.hpp"
6868
#import "${getUmbrellaHeaderName()}"
6969
70+
#if __has_include(<cxxreact/ReactNativeVersion.h>)
71+
#include <cxxreact/ReactNativeVersion.h>
72+
#if REACT_NATIVE_VERSION_MINOR >= 82
73+
#define ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
74+
#endif
75+
#endif
76+
7077
using namespace facebook;
7178
using namespace ${namespace};
7279
using namespace ${namespace}::views;
@@ -150,11 +157,13 @@ using namespace ${namespace}::views;
150157
swiftPart.maybePrepareForRecycle();
151158
}
152159
160+
#ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
153161
- (void)invalidate {
154162
${swiftNamespace}::${HybridTSpecCxx}& swiftPart = _hybridView->getSwiftPart();
155163
swiftPart.onDropView();
156164
[super invalidate];
157165
}
166+
#endif
158167
159168
@end
160169
`

packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridRecyclableTestViewComponent.mm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
#import "HybridRecyclableTestViewSpecSwift.hpp"
1818
#import "NitroTest-Swift-Cxx-Umbrella.hpp"
1919

20+
#if __has_include(<cxxreact/ReactNativeVersion.h>)
21+
#include <cxxreact/ReactNativeVersion.h>
22+
#if REACT_NATIVE_VERSION_MINOR >= 82
23+
#define ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
24+
#endif
25+
#endif
26+
2027
using namespace facebook;
2128
using namespace margelo::nitro::test;
2229
using namespace margelo::nitro::test::views;
@@ -104,10 +111,12 @@ - (void)prepareForRecycle {
104111
swiftPart.maybePrepareForRecycle();
105112
}
106113

114+
#ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
107115
- (void)invalidate {
108116
NitroTest::HybridRecyclableTestViewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
109117
swiftPart.onDropView();
110118
[super invalidate];
111119
}
120+
#endif
112121

113122
@end

packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridTestViewComponent.mm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
#import "HybridTestViewSpecSwift.hpp"
1818
#import "NitroTest-Swift-Cxx-Umbrella.hpp"
1919

20+
#if __has_include(<cxxreact/ReactNativeVersion.h>)
21+
#include <cxxreact/ReactNativeVersion.h>
22+
#if REACT_NATIVE_VERSION_MINOR >= 82
23+
#define ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
24+
#endif
25+
#endif
26+
2027
using namespace facebook;
2128
using namespace margelo::nitro::test;
2229
using namespace margelo::nitro::test::views;
@@ -119,10 +126,12 @@ - (void)prepareForRecycle {
119126
swiftPart.maybePrepareForRecycle();
120127
}
121128

129+
#ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
122130
- (void)invalidate {
123131
NitroTest::HybridTestViewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
124132
swiftPart.onDropView();
125133
[super invalidate];
126134
}
135+
#endif
127136

128137
@end

0 commit comments

Comments
 (0)