From 52fe1442818ecbb6cc770d58005ba0b9d4f8f219 Mon Sep 17 00:00:00 2001 From: Erwan Date: Tue, 27 Aug 2019 17:28:45 +0200 Subject: [PATCH] fix deprecated componentWillReceiveProps --- lib/KeyboardAwareHOC.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/KeyboardAwareHOC.js b/lib/KeyboardAwareHOC.js index c0d677f..725511b 100644 --- a/lib/KeyboardAwareHOC.js +++ b/lib/KeyboardAwareHOC.js @@ -238,9 +238,12 @@ function KeyboardAwareHOC( }) } - componentWillReceiveProps(nextProps: KeyboardAwareHOCProps) { - if (nextProps.viewIsInsideTabBar !== this.props.viewIsInsideTabBar) { - const keyboardSpace: number = nextProps.viewIsInsideTabBar + componentDidUpdate(prevProps: KeyboardAwareHOCProps) { + const {viewIsInsideTabBar: prevViewIsInsideTabBar} = prevProps; + const {viewIsInsideTabBar: nextViewIsInsideTabBar} = this.props; + + if (prevViewIsInsideTabBar !== nextViewIsInsideTabBar) { + const keyboardSpace: number = nextViewIsInsideTabBar ? _KAM_DEFAULT_TAB_BAR_HEIGHT : 0 if (this.state.keyboardSpace !== keyboardSpace) {