diff --git a/patches/react-native+0.71.2-alpha.3.patch b/patches/react-native+0.71.2-alpha.3.patch index 90112ee8f023..92076b1be28c 100644 --- a/patches/react-native+0.71.2-alpha.3.patch +++ b/patches/react-native+0.71.2-alpha.3.patch @@ -1,15 +1,87 @@ diff --git a/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js -index 2f48f9e..f59beee 100644 +index 2f48f9e..6418c76 100644 --- a/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js -@@ -128,6 +128,10 @@ class KeyboardAvoidingView extends React.Component { +@@ -65,6 +65,7 @@ class KeyboardAvoidingView extends React.Component { + _subscriptions: Array = []; + viewRef: {current: React.ElementRef | null, ...}; + _initialFrameHeight: number = 0; ++ _bottom: number = 0; + + constructor(props: Props) { + super(props); +@@ -107,18 +108,20 @@ class KeyboardAvoidingView extends React.Component { + + _onKeyboardChange = (event: ?KeyboardEvent) => { + this._keyboardEvent = event; ++ // $FlowFixMe[unused-promise] + this._updateBottomIfNecessary(); }; - _updateBottomIfNecessary = async () => { -+ if (!this.props.enabled) { -+ return; + _onLayout = async (event: ViewLayoutEvent) => { +- const wasFrameNull = this._frame == null; ++ const oldFrame = this._frame; + this._frame = event.nativeEvent.layout; + if (!this._initialFrameHeight) { + // save the initial frame height, before the keyboard is visible + this._initialFrameHeight = this._frame.height; + } + +- if (wasFrameNull) { ++ // update bottom height for the first time or when the height is changed ++ if (!oldFrame || oldFrame.height !== this._frame.height) { + await this._updateBottomIfNecessary(); + } + +@@ -127,20 +130,31 @@ class KeyboardAvoidingView extends React.Component { + } + }; + ++ // Avoid unnecessary renders if the KeyboardAvoidingView is disabled. ++ _setBottom = (value: number) => { ++ const {enabled = true} = this.props; ++ this._bottom = value; ++ if (enabled) { ++ this.setState({bottom: value}); + } ++ }; + + _updateBottomIfNecessary = async () => { if (this._keyboardEvent == null) { - this.setState({bottom: 0}); +- this.setState({bottom: 0}); ++ this._setBottom(0); return; + } + + const {duration, easing, endCoordinates} = this._keyboardEvent; + const height = await this._relativeKeyboardHeight(endCoordinates); + +- if (this.state.bottom === height) { ++ if (this._bottom === height) { + return; + } + +- if (duration && easing) { ++ this._setBottom(height); ++ ++ if (enabled && duration && easing) { + LayoutAnimation.configureNext({ + // We have to pass the duration equal to minimal accepted duration defined here: RCTLayoutAnimation.m + duration: duration > 10 ? duration : 10, +@@ -150,9 +164,15 @@ class KeyboardAvoidingView extends React.Component { + }, + }); + } +- this.setState({bottom: height}); + }; + ++ componentDidUpdate(_: Props, prevState: State): void { ++ const {enabled = true} = this.props; ++ if (enabled && this._bottom !== prevState.bottom) { ++ this.setState({bottom: this._bottom}); ++ } ++ } ++ + componentDidMount(): void { + if (Platform.OS === 'ios') { + this._subscriptions = [