Skip to content

Commit

Permalink
fix: Remove REACT_NATIVE_VERSION checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Jan 21, 2025
1 parent 35a4efb commit 7ddfc74
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,7 @@ export function createHybridObjectIntializer(): SourceFile[] {
const autolinkingClassName = `${NitroConfig.getAndroidCxxLibName()}OnLoad`

const jniRegistrations = getJNINativeRegistrations()
.map((r) => {
const code = `${r.namespace}::${r.className}::registerNatives();`
if (r.ifGuard != null) {
return `
#if ${r.ifGuard}
${code}
#endif`.trim()
} else {
return code
}
})
.map((r) => `${r.namespace}::${r.className}::registerNatives();`)
.filter(isNotDuplicate)

const autolinkedHybridObjects = NitroConfig.getAutolinkedHybridObjects()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export interface JNINativeRegistration {
namespace: string
className: string
import: SourceImport
ifGuard?: string
}

const jniNativeRegistrations: JNINativeRegistration[] = []
Expand Down
13 changes: 2 additions & 11 deletions packages/nitrogen/src/views/CppHybridViewComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ ${createFileMetadataString(`${component}.hpp`)}
#pragma once
#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78
#include <optional>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/NitroHash.hpp>
#include <NitroModules/CachedProp.hpp>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
Expand Down Expand Up @@ -158,10 +156,6 @@ namespace ${namespace} {
/* The actual view for "${spec.name}" needs to be implemented in platform-specific code. */
} // namespace ${namespace}
#else
#warning "View Component '${HybridT}' will be unavailable in React Native, because it requires React Native 78 or higher."
#endif
`.trim()

// .cpp code
Expand Down Expand Up @@ -193,12 +187,11 @@ ${name}([&]() -> CachedProp<${type}> {
${createFileMetadataString(`${component}.cpp`)}
#include "${component}.hpp"
#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78
#include <string>
#include <exception>
#include <utility>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/JSIConverter.hpp>
#include <react/renderer/core/RawValue.h>
#include <react/renderer/core/ShadowNode.h>
Expand Down Expand Up @@ -241,8 +234,6 @@ namespace ${namespace} {
}
} // namespace ${namespace}
#endif
`.trim()

const files: SourceFile[] = [
Expand Down
13 changes: 2 additions & 11 deletions packages/nitrogen/src/views/kotlin/KotlinHybridViewManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,8 @@ ${createFileMetadataString(`J${stateUpdaterName}.hpp`)}
#pragma once
#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78
#include <fbjni/fbjni.h>
#include <NitroModules/NitroDefines.hpp>
#include <react/fabric/StateWrapperImpl.h>
#include "${JHybridTSpec}.hpp"
Expand All @@ -138,8 +136,6 @@ public:
};
} // namespace ${cxxNamespace}
#endif
`.trim()

const propsUpdaterCalls = spec.properties.map((p) => {
Expand All @@ -154,10 +150,8 @@ if (props.${name}.isDirty) {
${createFileMetadataString(`J${stateUpdaterName}.cpp`)}
#include "J${stateUpdaterName}.hpp"
#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78
#include "views/${component}.hpp"
#include <NitroModules/NitroDefines.hpp>
namespace ${cxxNamespace} {
Expand All @@ -182,8 +176,6 @@ void J${stateUpdaterName}::updateViewProps(jni::alias_ref<jni::JClass>,
}
} // namespace ${cxxNamespace}
#endif
`.trim()

addJNINativeRegistration({
Expand All @@ -194,7 +186,6 @@ void J${stateUpdaterName}::updateViewProps(jni::alias_ref<jni::JClass>,
space: 'user',
language: 'c++',
},
ifGuard: `REACT_NATIVE_VERSION_MINOR >= 78`,
})

return [
Expand Down
5 changes: 1 addition & 4 deletions packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ if (newViewProps.${name}.isDirty) {
${createFileMetadataString(`${component}.mm`)}
#import "${component}.hpp"
#include <NitroModules/NitroDefines.hpp>
#if REACT_NATIVE_VERSION_MINOR >= 78
#import <memory>
#import <NitroModules/NitroDefines.hpp>
#import <react/renderer/componentregistry/ComponentDescriptorProvider.h>
#import <React/RCTViewComponentView.h>
#import <React/RCTComponentViewFactory.h>
Expand Down Expand Up @@ -123,8 +122,6 @@ using namespace ${namespace}::views;
}
@end
#endif
`

return [
Expand Down
10 changes: 0 additions & 10 deletions packages/react-native-nitro-modules/cpp/utils/NitroDefines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,4 @@
#define SWIFT_NONCOPYABLE
#endif

// React Native Support
#if __has_include(<cxxreact/ReactNativeVersion.h>)
#include <cxxreact/ReactNativeVersion.h>
#endif
#ifndef REACT_NATIVE_VERSION_MINOR
#define REACT_NATIVE_VERSION_MAJOR 0
#define REACT_NATIVE_VERSION_MINOR 0
#define REACT_NATIVE_VERSION_PATCH 0
#endif

#endif /* NitroDefines_h */

0 comments on commit 7ddfc74

Please sign in to comment.