Skip to content

Commit

Permalink
Fixed string ref which was causing alert on react <Strictmode> (#23146)
Browse files Browse the repository at this point in the history
Summary:
Changelog:
----------
[General] [Fixed] - After using React's `<StricMode>` it was discovered that a string ref was set, which is bad practice.
Pull Request resolved: #23146

Differential Revision: D13802397

Pulled By: cpojer

fbshipit-source-id: c2744877b25ad59eb1e4e9ce48a45e762f227b56
  • Loading branch information
rsmelo92 authored and facebook-github-bot committed Jan 24, 2019
1 parent f4def00 commit e4d7fc0
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Libraries/Components/Keyboard/KeyboardAvoidingView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -66,10 +64,13 @@ class KeyboardAvoidingView extends React.Component<Props, State> {

_frame: ?ViewLayout = null;
_subscriptions: Array<EmitterSubscription> = [];
viewRef: {current: React.ElementRef<any> | null};

state = {
bottom: 0,
};
constructor(props: Props) {
super(props);
this.state = {bottom: 0};
this.viewRef = React.createRef();
}

_relativeKeyboardHeight(keyboardFrame): number {
const frame = this._frame;
Expand Down Expand Up @@ -171,7 +172,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
}
return (
<View
ref={viewRef}
ref={this.viewRef}
style={StyleSheet.compose(
style,
heightStyle,
Expand All @@ -185,7 +186,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
case 'position':
return (
<View
ref={viewRef}
ref={this.viewRef}
style={style}
onLayout={this._onLayout}
{...props}>
Expand All @@ -204,7 +205,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
case 'padding':
return (
<View
ref={viewRef}
ref={this.viewRef}
style={StyleSheet.compose(
style,
{paddingBottom: bottomHeight},
Expand All @@ -218,7 +219,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
default:
return (
<View
ref={viewRef}
ref={this.viewRef}
onLayout={this._onLayout}
style={style}
{...props}>
Expand Down

0 comments on commit e4d7fc0

Please sign in to comment.