Skip to content

Commit 5c5e6cd

Browse files
zoontekmeta-codesync[bot]
authored andcommitted
Deprecate DrawerLayoutAndroid (#57397)
Summary: Deprecates `DrawerLayoutAndroid` as part of the effort to keep core lean. It is Android only, and `react-native-drawer-layout` is a better, cross-platform alternative. This adds a `deprecated` JSDoc tag to the component and its props (Flow and TypeScript) and a one-time runtime warning when the component is imported, pointing users to `react-native-drawer-layout`. No behavior changes. ## Changelog: [ANDROID] [DEPRECATED] - Deprecate `DrawerLayoutAndroid`, use `react-native-drawer-layout` instead Pull Request resolved: #57397 Test Plan: - `deprecated` shows a strikethrough on `DrawerLayoutAndroid` in editors. - Importing/rendering `DrawerLayoutAndroid` logs the deprecation warning once, pointing to `react-native-drawer-layout`. Reviewed By: javache Differential Revision: D110334227 Pulled By: Abbondanzo fbshipit-source-id: 40edd2a4e997ba3ab350c7b7229beb237e83a57b
1 parent 721b1cf commit 5c5e6cd

4 files changed

Lines changed: 32 additions & 2 deletions

File tree

packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ const DRAWER_STATES = ['Idle', 'Dragging', 'Settling'] as const;
3535
/**
3636
* React component that wraps the platform `DrawerLayout` (Android only). The Drawer (typically used for navigation) is rendered with `renderNavigationView` and direct children are the main view. The navigation view is initially not visible on the screen, but can be pulled in from the side of the window specified by the `drawerPosition` prop and its width can be set by the `drawerWidth` prop.
3737
*
38-
* @see https://reactnative.dev/docs/drawerlayoutandroid
38+
* DrawerLayoutAndroid is deprecated and will be removed in a future release.
39+
* Use `react-native-drawer-layout` instead.
40+
*
41+
* @see https://reactnavigation.org/docs/drawer-layout/
3942
* @platform android
43+
* @deprecated
4044
*/
4145
class DrawerLayoutAndroid
4246
extends React.Component<DrawerLayoutAndroidProps, DrawerLayoutAndroidState>

packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ export interface DrawerSlideEvent
2121
extends NativeSyntheticEvent<NativeTouchEvent> {}
2222

2323
/**
24-
* @see DrawerLayoutAndroid.android.js
24+
* DrawerLayoutAndroid is deprecated and will be removed in a future release.
25+
* Use `react-native-drawer-layout` instead.
26+
* @see https://reactnavigation.org/docs/drawer-layout/
27+
* @deprecated
2528
*/
2629
export interface DrawerLayoutAndroidProps extends ViewProps {
2730
/**
@@ -123,6 +126,12 @@ interface DrawerPosition {
123126
declare class DrawerLayoutAndroidComponent extends React.Component<DrawerLayoutAndroidProps> {}
124127
declare const DrawerLayoutAndroidBase: Constructor<HostInstance> &
125128
typeof DrawerLayoutAndroidComponent;
129+
/**
130+
* DrawerLayoutAndroid is deprecated and will be removed in a future release.
131+
* Use `react-native-drawer-layout` instead.
132+
* @see https://reactnavigation.org/docs/drawer-layout/
133+
* @deprecated
134+
*/
126135
export class DrawerLayoutAndroid extends DrawerLayoutAndroidBase {
127136
/**
128137
* drawer's positions.

packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ export type DrawerSlideEvent = NativeSyntheticEvent<
2727
}>,
2828
>;
2929

30+
/**
31+
* DrawerLayoutAndroid is deprecated and will be removed in a future release.
32+
* Use `react-native-drawer-layout` instead.
33+
* @see https://reactnavigation.org/docs/drawer-layout/
34+
* @deprecated
35+
*/
3036
export type DrawerLayoutAndroidProps = Readonly<{
3137
...ViewProps,
3238

packages/react-native/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,18 @@ module.exports = {
3838
get Button() {
3939
return require('./Libraries/Components/Button').default;
4040
},
41+
/**
42+
* @deprecated DrawerLayoutAndroid is deprecated and will be removed in a future release.
43+
* Use 'react-native-drawer-layout' instead.
44+
* See https://reactnavigation.org/docs/drawer-layout/
45+
*/
4146
get DrawerLayoutAndroid() {
47+
warnOnce(
48+
'drawer-layout-android-deprecated',
49+
'DrawerLayoutAndroid is deprecated and will be removed in a future release. ' +
50+
"Use 'react-native-drawer-layout' instead. " +
51+
'See https://reactnavigation.org/docs/drawer-layout/',
52+
);
4253
return require('./Libraries/Components/DrawerAndroid/DrawerLayoutAndroid')
4354
.default;
4455
},

0 commit comments

Comments
 (0)