Align Keyboard types with OSS (#49623)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49623

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D70083211

fbshipit-source-id: c91d3cd7e8f4ad8770bc686768103b43611d4ebb
This commit is contained in:
Jakub Piasecki
2025-02-25 01:23:04 -08:00
committed by Facebook GitHub Bot
parent 091f542a2e
commit dee6168027
3 changed files with 15 additions and 9 deletions
@@ -25,7 +25,7 @@ import View from '../View/View';
import Keyboard from './Keyboard';
import * as React from 'react';
type Props = $ReadOnly<{
export type KeyboardAvoidingViewProps = $ReadOnly<{
...ViewProps,
/**
@@ -59,7 +59,10 @@ type State = {
* View that moves out of the way when the keyboard appears by automatically
* adjusting its height, position, or bottom padding.
*/
class KeyboardAvoidingView extends React.Component<Props, State> {
class KeyboardAvoidingView extends React.Component<
KeyboardAvoidingViewProps,
State,
> {
_frame: ?ViewLayout = null;
_keyboardEvent: ?KeyboardEvent = null;
_subscriptions: Array<EventSubscription> = [];
@@ -67,7 +70,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
_initialFrameHeight: number = 0;
_bottom: number = 0;
constructor(props: Props) {
constructor(props: KeyboardAvoidingViewProps) {
super(props);
this.state = {bottom: 0};
this.viewRef = React.createRef();
@@ -175,7 +178,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
}
};
componentDidUpdate(_: Props, prevState: State): void {
componentDidUpdate(_: KeyboardAvoidingViewProps, prevState: State): void {
const enabled = this.props.enabled ?? true;
if (enabled && this._bottom !== prevState.bottom) {
this.setState({bottom: this._bottom});
@@ -1528,7 +1528,7 @@ declare export default Keyboard;
`;
exports[`public API should not change unintentionally Libraries/Components/Keyboard/KeyboardAvoidingView.js 1`] = `
"type Props = $ReadOnly<{
"export type KeyboardAvoidingViewProps = $ReadOnly<{
...ViewProps,
behavior?: ?(\\"height\\" | \\"position\\" | \\"padding\\"),
contentContainerStyle?: ?ViewStyleProp,
@@ -1538,10 +1538,12 @@ exports[`public API should not change unintentionally Libraries/Components/Keybo
type State = {
bottom: number,
};
declare class KeyboardAvoidingView extends React.Component<Props, State> {
declare class KeyboardAvoidingView
extends React.Component<KeyboardAvoidingViewProps, State>
{
viewRef: { current: React.ElementRef<typeof View> | null, ... };
constructor(props: Props): void;
componentDidUpdate(_: Props, prevState: State): void;
constructor(props: KeyboardAvoidingViewProps): void;
componentDidUpdate(_: KeyboardAvoidingViewProps, prevState: State): void;
componentDidMount(): void;
componentWillUnmount(): void;
render(): React.Node;
+2 -1
View File
@@ -39,7 +39,8 @@ const ENTRY_POINTS = [
'packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js',
'packages/react-native/Libraries/Components/Button.js',
'packages/react-native/Libraries/Components/Clipboard/Clipboard.js',
'packages/react-native/Libraries/Components/LayoutConformance/LayoutConformance.js',
'packages/react-native/Libraries/Components/Keyboard/Keyboard.js',
'packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js',
'packages/react-native/Libraries/Components/ToastAndroid/ToastAndroid.js',
'packages/react-native/Libraries/Components/ScrollView/ScrollView.js',
'packages/react-native/Libraries/Interaction/InteractionManager.js',