Skip to content

Commit 6730927

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
Fix infinite loop in KeyboardAvoidingView
Summary: Changelog: [General][Fixed] Fix stalling UI due to a bug in KeyboardAvoidingView I introduced this bug in D22764192 (b08fff6). The stalling was caused by onLayout in JavaScript triggering native layout which called onLayout in JavaScript without terminating condition. The fix is to only cause native layout once from JavaScript's onLayout function. This makes sure both Fabric and Paper works correctly and UI stall isn't caused. Resolves: #30495 #30532 Reviewed By: TheSavior Differential Revision: D25522362 fbshipit-source-id: 602e540bb1c40ae4f421b3e6ebc5a047cd920c17
1 parent 7485208 commit 6730927

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Libraries/Components/Keyboard/KeyboardAvoidingView.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,16 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
9797
};
9898

9999
_onLayout = (event: ViewLayoutEvent) => {
100+
const wasFrameNull = this._frame == null;
100101
this._frame = event.nativeEvent.layout;
101102
if (!this._initialFrameHeight) {
102103
// save the initial frame height, before the keyboard is visible
103104
this._initialFrameHeight = this._frame.height;
104105
}
105106

106-
this._updateBottomIfNecesarry();
107+
if (wasFrameNull) {
108+
this._updateBottomIfNecesarry();
109+
}
107110
};
108111

109112
_updateBottomIfNecesarry = () => {

0 commit comments

Comments
 (0)