Skip to content

Commit aa8d623

Browse files
Swordsman-Inactionalvaromb
authored andcommitted
Fix: only set state when prop changes (APSL#209)
1 parent 425736b commit aa8d623

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/KeyboardAwareHOC.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,13 @@ function listenToKeyboardEvents(ScrollableComponent: React$Component) {
114114
}
115115

116116
componentWillReceiveProps(nextProps: KeyboardAwareHOCProps) {
117-
const keyboardSpace: number = nextProps.viewIsInsideTabBar
118-
? _KAM_DEFAULT_TAB_BAR_HEIGHT
119-
: 0
120-
if (this.state.keyboardSpace !== keyboardSpace) {
121-
this.setState({ keyboardSpace })
117+
if (nextProps.viewIsInsideTabBar !== this.props.viewIsInsideTabBar) {
118+
const keyboardSpace: number = nextProps.viewIsInsideTabBar
119+
? _KAM_DEFAULT_TAB_BAR_HEIGHT
120+
: 0
121+
if (this.state.keyboardSpace !== keyboardSpace) {
122+
this.setState({ keyboardSpace })
123+
}
122124
}
123125
}
124126

0 commit comments

Comments
 (0)