Skip to content

Commit

Permalink
Merge pull request #22538 from ntdiary/issue-22206
Browse files Browse the repository at this point in the history
fix enabled property warning
  • Loading branch information
robertjchen authored Jul 10, 2023
2 parents a1ebcdb + eff6d73 commit 073b9b5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions patches/react-native+0.71.2-alpha.3.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js
index 2f48f9e..6418c76 100644
index 2f48f9e..ac7a416 100644
--- a/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js
+++ b/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js
@@ -65,6 +65,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
Expand Down Expand Up @@ -33,13 +33,13 @@ index 2f48f9e..6418c76 100644
await this._updateBottomIfNecessary();
}

@@ -127,20 +130,31 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
@@ -127,20 +130,32 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
}
};

+ // Avoid unnecessary renders if the KeyboardAvoidingView is disabled.
+ _setBottom = (value: number) => {
+ const {enabled = true} = this.props;
+ const enabled = this.props.enabled ?? true;
+ this._bottom = value;
+ if (enabled) {
+ this.setState({bottom: value});
Expand All @@ -64,19 +64,20 @@ index 2f48f9e..6418c76 100644
- if (duration && easing) {
+ this._setBottom(height);
+
+ const enabled = this.props.enabled ?? true;
+ 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<Props, State> {
@@ -150,9 +165,15 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
},
});
}
- this.setState({bottom: height});
};

+ componentDidUpdate(_: Props, prevState: State): void {
+ const {enabled = true} = this.props;
+ const enabled = this.props.enabled ?? true;
+ if (enabled && this._bottom !== prevState.bottom) {
+ this.setState({bottom: this._bottom});
+ }
Expand Down

0 comments on commit 073b9b5

Please sign in to comment.