Skip to content

Commit 0105408

Browse files
cortinicothymikee
andauthoredJan 16, 2024
feat: Deprecate unstable_reactLegacyComponentNames (#2264)
* Deprecate unstable_reactLegacyComponentNames * add warning and todos for removal * add ios warning as well --------- Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
1 parent ac90938 commit 0105408

File tree

6 files changed

+32
-23
lines changed

6 files changed

+32
-23
lines changed
 

‎docs/projects.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ The following settings are available on iOS and Android:
6868
type IOSProjectParams = {
6969
sourceDir?: string;
7070
watchModeCommandParams?: string[];
71-
unstable_reactLegacyComponentNames?: string[] | null;
7271
automaticPodsInstallation?: boolean;
7372
};
7473

@@ -79,7 +78,6 @@ type AndroidProjectParams = {
7978
packageName?: string;
8079
dependencyConfiguration?: string;
8180
watchModeCommandParams?: string[];
82-
unstable_reactLegacyComponentNames?: string[] | null;
8381
};
8482
```
8583

@@ -94,7 +92,8 @@ Array of strings that will be passed to the `npx react-native run-ios` command w
9492

9593
#### project.ios.unstable_reactLegacyComponentNames
9694

97-
> Note: Only applicable when new architecture is turned on.
95+
> [!CAUTION]
96+
> Deprecated in React Native 0.74, where this behavior is detected automatically and this config does nothing. You can safely remove it from your project.
9897
9998
Please note that this is part of the **Unstable Fabric Interop Layer**, and might be subject to breaking change in the future,
10099
hence the `unstable_` prefix.
@@ -104,6 +103,8 @@ This will allow you to use libraries that haven't been migrated yet on the New A
104103

105104
The list should contain the name of the components, as they're registered in the ViewManagers (i.e. just `"Button"`).
106105

106+
Since React Native 0.74, this property is ignored as the Interop Layer is **Automatic**, you don't need to register the Legacy Components anymore and they will be discovered automatically.
107+
107108
#### project.ios.automaticPodsInstallation
108109

109110
A boolean value to determine if you want to automatically install CocoaPods when running `run-ios` or `build-ios` command when:
@@ -141,7 +142,8 @@ Array of strings that will be passed to the `npx react-native run-android` comma
141142

142143
#### project.android.unstable_reactLegacyComponentNames
143144

144-
> Note: Only applicable when new architecture is turned on.
145+
> [!CAUTION]
146+
> Deprecated in React Native 0.74, where this behavior is detected automatically and this config does nothing. You can safely remove it from your project.
145147
146148
Please note that this is part of the **Unstable Fabric Interop Layer**, and might be subject to breaking change in the future,
147149
hence the `unstable_` prefix.
@@ -151,6 +153,8 @@ This will allow you to use libraries that haven't been migrated yet on the New A
151153

152154
The list should contain the name of the components, as they're registered in the ViewManagers (i.e. just `"Button"`).
153155

156+
Since React Native 0.74, this property is ignored as the Interop Layer is **Automatic**, you don't need to register the Legacy Components anymore and they will be discovered automatically.
157+
154158
### platforms
155159

156160
A object with platforms defined inside a project. You can check the format and options available [`here`](platforms.md#platform-interface)

‎packages/cli-config/src/schema.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,11 @@ export const projectConfig = t
152152
.object({
153153
sourceDir: t.string(),
154154
watchModeCommandParams: t.array().items(t.string()),
155+
// @todo remove for RN 0.75
155156
unstable_reactLegacyComponentNames: t
156157
.array()
157158
.items(t.string())
158-
.default([]),
159+
.optional(),
159160
automaticPodsInstallation: t.bool().default(false),
160161
})
161162
.default({}),
@@ -168,10 +169,11 @@ export const projectConfig = t
168169
packageName: t.string(),
169170
dependencyConfiguration: t.string(),
170171
watchModeCommandParams: t.array().items(t.string()),
172+
// @todo remove for RN 0.75
171173
unstable_reactLegacyComponentNames: t
172174
.array()
173175
.items(t.string())
174-
.default([]),
176+
.optional(),
175177
})
176178
.default({}),
177179
})

‎packages/cli-platform-android/native_modules.gradle

-13
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ class ReactNativeModules {
142142
private String packageName
143143
private File root
144144
private ArrayList<HashMap<String, String>> reactNativeModules
145-
private ArrayList<String> unstable_reactLegacyComponentNames
146145
private HashMap<String, ArrayList> reactNativeModulesBuildVariants
147146
private String reactNativeVersion
148147

@@ -157,7 +156,6 @@ class ReactNativeModules {
157156
this.reactNativeModules = nativeModules
158157
this.reactNativeModulesBuildVariants = reactNativeModulesBuildVariants
159158
this.packageName = androidProject["packageName"]
160-
this.unstable_reactLegacyComponentNames = androidProject["unstable_reactLegacyComponentNames"]
161159
this.reactNativeVersion = reactNativeVersion
162160
}
163161

@@ -296,7 +294,6 @@ class ReactNativeModules {
296294

297295
void generateRncliCpp(File outputDir, String generatedFileName, String generatedFileContentsTemplate) {
298296
ArrayList<HashMap<String, String>> packages = this.reactNativeModules
299-
ArrayList<String> unstable_reactLegacyComponentNames = this.unstable_reactLegacyComponentNames
300297
String rncliCppIncludes = ""
301298
String rncliCppModuleProviders = ""
302299
String rncliCppComponentDescriptors = ""
@@ -333,16 +330,6 @@ class ReactNativeModules {
333330
}.join("\n")
334331
}
335332

336-
rncliReactLegacyComponentDescriptors = unstable_reactLegacyComponentNames.collect {
337-
" providerRegistry->add(concreteComponentDescriptorProvider<UnstableLegacyViewManagerInteropComponentDescriptor<${it}>>());"
338-
}.join("\n")
339-
rncliReactLegacyComponentNames = unstable_reactLegacyComponentNames.collect {
340-
"extern const char ${it}[] = \"${it}\";"
341-
}.join("\n")
342-
if (unstable_reactLegacyComponentNames && unstable_reactLegacyComponentNames.size() > 0) {
343-
rncliCppIncludes += "\n#include <react/renderer/components/legacyviewmanagerinterop/UnstableLegacyViewManagerInteropComponentDescriptor.h>"
344-
}
345-
346333
String generatedFileContents = generatedFileContentsTemplate
347334
.replace("{{ rncliCppIncludes }}", rncliCppIncludes)
348335
.replace("{{ rncliCppModuleProviders }}", rncliCppModuleProviders)

‎packages/cli-platform-android/src/config/index.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
import {findLibraryName} from './findLibraryName';
2525
import {findComponentDescriptors} from './findComponentDescriptors';
2626
import {findBuildGradle} from './findBuildGradle';
27-
import {CLIError} from '@react-native-community/cli-tools';
27+
import {CLIError, logger} from '@react-native-community/cli-tools';
2828
import getMainActivity from './getMainActivity';
2929

3030
/**
@@ -68,6 +68,13 @@ export function projectConfig(
6868
: packageName;
6969
const mainActivity = getMainActivity(manifestPath || '') ?? '';
7070

71+
// @todo remove for RN 0.75
72+
if (userConfig.unstable_reactLegacyComponentNames) {
73+
logger.warn(
74+
'The "project.android.unstable_reactLegacyComponentNames" config option is not necessary anymore for React Native 0.74 and does nothing. Please remove it from the "react-native.config.js" file.',
75+
);
76+
}
77+
7178
return {
7279
sourceDir,
7380
appName,
@@ -76,8 +83,8 @@ export function projectConfig(
7683
mainActivity,
7784
dependencyConfiguration: userConfig.dependencyConfiguration,
7885
watchModeCommandParams: userConfig.watchModeCommandParams,
79-
unstable_reactLegacyComponentNames:
80-
userConfig.unstable_reactLegacyComponentNames,
86+
// @todo remove for RN 0.75
87+
unstable_reactLegacyComponentNames: undefined,
8188
};
8289
}
8390

‎packages/cli-platform-apple/src/config/index.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
IOSProjectConfig,
1919
IOSDependencyConfig,
2020
} from '@react-native-community/cli-types';
21-
import {CLIError} from '@react-native-community/cli-tools';
21+
import {CLIError, logger} from '@react-native-community/cli-tools';
2222
import {BuilderCommand} from '../types';
2323

2424
/**
@@ -47,6 +47,13 @@ export const getProjectConfig =
4747

4848
const xcodeProject = findXcodeProject(fs.readdirSync(sourceDir));
4949

50+
// @ts-ignore @todo remove for RN 0.75
51+
if (userConfig.unstable_reactLegacyComponentNames) {
52+
logger.warn(
53+
'The "project.ios.unstable_reactLegacyComponentNames" config option is not necessary anymore for React Native 0.74 and does nothing. Please remove it from the "react-native.config.js" file.',
54+
);
55+
}
56+
5057
return {
5158
sourceDir,
5259
watchModeCommandParams: userConfig.watchModeCommandParams,

‎packages/cli-types/src/android.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface AndroidProjectConfig {
66
mainActivity: string;
77
dependencyConfiguration?: string;
88
watchModeCommandParams?: string[];
9+
// @todo remove for RN 0.75
910
unstable_reactLegacyComponentNames?: string[] | null;
1011
}
1112

@@ -16,6 +17,7 @@ export type AndroidProjectParams = {
1617
packageName?: string;
1718
dependencyConfiguration?: string;
1819
watchModeCommandParams?: string[];
20+
// @todo remove for RN 0.75
1921
unstable_reactLegacyComponentNames?: string[] | null;
2022
};
2123

0 commit comments

Comments
 (0)
Please sign in to comment.