Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { PropsWithChildren, ReactElement } from 'react';
import * as React from 'react';
import type {
DrawerLayoutAndroid as RNDrawerLayoutAndroid,
DrawerLayoutAndroidProps as RNDrawerLayoutAndroidProps,
FlatListProps as RNFlatListProps,
ScrollViewProps as RNScrollViewProps,
SwitchProps as RNSwitchProps,
TextInputProps as RNTextInputProps,
} from 'react-native';
import {
DrawerLayoutAndroid as RNDrawerLayoutAndroid,
FlatList as RNFlatList,
RefreshControl as RNRefreshControl,
ScrollView as RNScrollView,
Expand Down Expand Up @@ -96,18 +96,44 @@ export const LegacyTextInput =
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type LegacyTextInput = typeof LegacyTextInput & RNTextInput;

// RN's `DrawerLayoutAndroid` export is a getter that logs a deprecation
// warning on access, so resolve it on first render instead of module load.
// `require` is used on purpose: `import * as RN` would read every export
// eagerly under Metro's `experimentalImportSupport`.
let DrawerLayoutAndroidImpl: typeof RNDrawerLayoutAndroid | undefined;

const LazyDrawerLayoutAndroid = (
props: PropsWithChildren<RNDrawerLayoutAndroidProps> & {
ref?: React.Ref<React.ComponentRef<typeof RNDrawerLayoutAndroid> | null>;
}
) => {
if (!DrawerLayoutAndroidImpl) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { DrawerLayoutAndroid } = require('react-native') as {
DrawerLayoutAndroid: typeof RNDrawerLayoutAndroid;
};
DrawerLayoutAndroidImpl = DrawerLayoutAndroid;
}
return <DrawerLayoutAndroidImpl {...props} />;
};
LazyDrawerLayoutAndroid.displayName = 'DrawerLayoutAndroid';

/**
* @deprecated use `DrawerLayoutAndroid` instead
*/
export const LegacyDrawerLayoutAndroid: React.ComponentType<
PropsWithChildren<RNDrawerLayoutAndroidProps> & NativeViewGestureHandlerProps
PropsWithChildren<RNDrawerLayoutAndroidProps> &
NativeViewGestureHandlerProps & {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ref?: React.Ref<React.ComponentType<any> | null>;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
> = createNativeWrapper<PropsWithChildren<RNDrawerLayoutAndroidProps>>(
RNDrawerLayoutAndroid,
LazyDrawerLayoutAndroid,
{ disallowInterruption: true }
);
Comment on lines +105 to 133

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forwardRef is not needed since React 19

// eslint-disable-next-line @typescript-eslint/no-redeclare
export type LegacyDrawerLayoutAndroid = typeof LegacyDrawerLayoutAndroid &
RNDrawerLayoutAndroid;
React.ComponentRef<typeof RNDrawerLayoutAndroid>;

/**
* @deprecated use `FlatList` instead
Expand Down
Loading