Fixed string ref which was causing alert on react <Strictmode> (#23146)
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: https://github.com/facebook/react-native/pull/23146 Differential Revision: D13802397 Pulled By: cpojer fbshipit-source-id: c2744877b25ad59eb1e4e9ce48a45e762f227b56
This commit is contained in:
parent
f4def0062c
commit
e4d7fc06cb
|
@ -52,8 +52,6 @@ type State = {|
|
||||||
bottom: number,
|
bottom: number,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
const viewRef = 'VIEW';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View that moves out of the way when the keyboard appears by automatically
|
* View that moves out of the way when the keyboard appears by automatically
|
||||||
* adjusting its height, position, or bottom padding.
|
* adjusting its height, position, or bottom padding.
|
||||||
|
@ -66,10 +64,13 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
|
||||||
|
|
||||||
_frame: ?ViewLayout = null;
|
_frame: ?ViewLayout = null;
|
||||||
_subscriptions: Array<EmitterSubscription> = [];
|
_subscriptions: Array<EmitterSubscription> = [];
|
||||||
|
viewRef: {current: React.ElementRef<any> | null};
|
||||||
|
|
||||||
state = {
|
constructor(props: Props) {
|
||||||
bottom: 0,
|
super(props);
|
||||||
};
|
this.state = {bottom: 0};
|
||||||
|
this.viewRef = React.createRef();
|
||||||
|
}
|
||||||
|
|
||||||
_relativeKeyboardHeight(keyboardFrame): number {
|
_relativeKeyboardHeight(keyboardFrame): number {
|
||||||
const frame = this._frame;
|
const frame = this._frame;
|
||||||
|
@ -171,7 +172,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
ref={viewRef}
|
ref={this.viewRef}
|
||||||
style={StyleSheet.compose(
|
style={StyleSheet.compose(
|
||||||
style,
|
style,
|
||||||
heightStyle,
|
heightStyle,
|
||||||
|
@ -185,7 +186,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
|
||||||
case 'position':
|
case 'position':
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
ref={viewRef}
|
ref={this.viewRef}
|
||||||
style={style}
|
style={style}
|
||||||
onLayout={this._onLayout}
|
onLayout={this._onLayout}
|
||||||
{...props}>
|
{...props}>
|
||||||
|
@ -204,7 +205,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
|
||||||
case 'padding':
|
case 'padding':
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
ref={viewRef}
|
ref={this.viewRef}
|
||||||
style={StyleSheet.compose(
|
style={StyleSheet.compose(
|
||||||
style,
|
style,
|
||||||
{paddingBottom: bottomHeight},
|
{paddingBottom: bottomHeight},
|
||||||
|
@ -218,7 +219,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
ref={viewRef}
|
ref={this.viewRef}
|
||||||
onLayout={this._onLayout}
|
onLayout={this._onLayout}
|
||||||
style={style}
|
style={style}
|
||||||
{...props}>
|
{...props}>
|
||||||
|
|
Loading…
Reference in New Issue