Skip to content

Commit

Permalink
fix: configure cli for Android only when RNCLI version >= 9.0.0 (#1615)
Browse files Browse the repository at this point in the history
## Description

Fixes #1614

#1611 added `react-native.config.js` file to the library which uses
features supported since `@react-native-cli@9.0.0` thus causing library
fail to link while on Paper with React Native < 0.70.

This fix is borrowed from `react-native-safe-area-context`.

## Changes

Added check for `@react-native-community/cli-platform-android` version
in `react-native.config.js`.

## Test code and steps to reproduce

--

## Checklist

- [x] Ensured that CI passes
  • Loading branch information
kkafar authored Oct 12, 2022
1 parent a6fc428 commit 0f684a7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions react-native.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
let supportsCodegenConfig = false;
try {
const rnCliAndroidVersion =
require('@react-native-community/cli-platform-android/package.json').version;
const [major] = rnCliAndroidVersion.split('.');
supportsCodegenConfig = major >= 9;
} catch (e) {
// ignore
}

module.exports = {
dependency: {
platforms: {
android: {
android: supportsCodegenConfig ? {
componentDescriptors: [
"RNSFullWindowOverlayComponentDescriptor",
"RNSScreenContainerComponentDescriptor",
Expand All @@ -13,7 +23,7 @@ module.exports = {
'RNSScreenComponentDescriptor'
],
cmakeListsPath: "../android/src/main/jni/CMakeLists.txt"
},
} : {},
},
},
}

0 comments on commit 0f684a7

Please sign in to comment.