From e4d7fc06cb74fde24b508212a52a03122de596fa Mon Sep 17 00:00:00 2001 From: Rafael Melo Date: Thu, 24 Jan 2019 08:20:46 -0800 Subject: [PATCH] Fixed string ref which was causing alert on react (#23146) Summary: Changelog: ---------- [General] [Fixed] - After using React's `` it was discovered that a string ref was set, which is bad practice. Pull Request resolved: https://github.com/facebook/react-native/pull/23146 Differential Revision: D13802397 Pulled By: cpojer fbshipit-source-id: c2744877b25ad59eb1e4e9ce48a45e762f227b56 --- .../Keyboard/KeyboardAvoidingView.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/Libraries/Components/Keyboard/KeyboardAvoidingView.js index 6bfa6df2c..febb22205 100644 --- a/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -52,8 +52,6 @@ type State = {| bottom: number, |}; -const viewRef = 'VIEW'; - /** * View that moves out of the way when the keyboard appears by automatically * adjusting its height, position, or bottom padding. @@ -66,10 +64,13 @@ class KeyboardAvoidingView extends React.Component { _frame: ?ViewLayout = null; _subscriptions: Array = []; + viewRef: {current: React.ElementRef | null}; - state = { - bottom: 0, - }; + constructor(props: Props) { + super(props); + this.state = {bottom: 0}; + this.viewRef = React.createRef(); + } _relativeKeyboardHeight(keyboardFrame): number { const frame = this._frame; @@ -171,7 +172,7 @@ class KeyboardAvoidingView extends React.Component { } return ( { case 'position': return ( @@ -204,7 +205,7 @@ class KeyboardAvoidingView extends React.Component { case 'padding': return ( { default: return (