mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
Prettier React Native Libraries
Reviewed By: sahrens Differential Revision: D7961488 fbshipit-source-id: 05f9b8b0b91ae77f9040a5321ccc18f7c3c1ce9a
This commit is contained in:
committed by
Facebook Github Bot
parent
1e2de71290
commit
d01ab66b47
@@ -4,8 +4,10 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const LayoutAnimation = require('LayoutAnimation');
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const createReactClass = require('create-react-class');
|
||||
@@ -66,9 +68,9 @@ const KeyboardAvoidingView = createReactClass({
|
||||
*/
|
||||
keyboardVerticalOffset: PropTypes.number.isRequired,
|
||||
/**
|
||||
* This is to allow us to manually control which KAV shuld take effect when
|
||||
* having more than one KAV at the same screen
|
||||
*/
|
||||
* This is to allow us to manually control which KAV shuld take effect when
|
||||
* having more than one KAV at the same screen
|
||||
*/
|
||||
enabled: PropTypes.bool.isRequired,
|
||||
},
|
||||
|
||||
@@ -130,10 +132,16 @@ const KeyboardAvoidingView = createReactClass({
|
||||
this.frame = event.nativeEvent.layout;
|
||||
},
|
||||
|
||||
UNSAFE_componentWillUpdate(nextProps: Object, nextState: Object, nextContext?: Object): void {
|
||||
if (nextState.bottom === this.state.bottom &&
|
||||
this.props.behavior === 'height' &&
|
||||
nextProps.behavior === 'height') {
|
||||
UNSAFE_componentWillUpdate(
|
||||
nextProps: Object,
|
||||
nextState: Object,
|
||||
nextContext?: Object,
|
||||
): void {
|
||||
if (
|
||||
nextState.bottom === this.state.bottom &&
|
||||
this.props.behavior === 'height' &&
|
||||
nextProps.behavior === 'height'
|
||||
) {
|
||||
// If the component rerenders without an internal state change, e.g.
|
||||
// triggered by parent component re-rendering, no need for bottom to change.
|
||||
nextState.bottom = 0;
|
||||
@@ -154,7 +162,7 @@ const KeyboardAvoidingView = createReactClass({
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
this.subscriptions.forEach((sub) => sub.remove());
|
||||
this.subscriptions.forEach(sub => sub.remove());
|
||||
},
|
||||
|
||||
render(): React.Element<any> {
|
||||
@@ -172,17 +180,25 @@ const KeyboardAvoidingView = createReactClass({
|
||||
heightStyle = {height: this.frame.height - bottomHeight, flex: 0};
|
||||
}
|
||||
return (
|
||||
<View ref={viewRef} style={[style, heightStyle]} onLayout={this._onLayout} {...props}>
|
||||
<View
|
||||
ref={viewRef}
|
||||
style={[style, heightStyle]}
|
||||
onLayout={this._onLayout}
|
||||
{...props}>
|
||||
{children}
|
||||
</View>
|
||||
);
|
||||
|
||||
case 'position':
|
||||
const positionStyle = {bottom: bottomHeight};
|
||||
const { contentContainerStyle } = this.props;
|
||||
const {contentContainerStyle} = this.props;
|
||||
|
||||
return (
|
||||
<View ref={viewRef} style={style} onLayout={this._onLayout} {...props}>
|
||||
<View
|
||||
ref={viewRef}
|
||||
style={style}
|
||||
onLayout={this._onLayout}
|
||||
{...props}>
|
||||
<View style={[contentContainerStyle, positionStyle]}>
|
||||
{children}
|
||||
</View>
|
||||
@@ -192,14 +208,22 @@ const KeyboardAvoidingView = createReactClass({
|
||||
case 'padding':
|
||||
const paddingStyle = {paddingBottom: bottomHeight};
|
||||
return (
|
||||
<View ref={viewRef} style={[style, paddingStyle]} onLayout={this._onLayout} {...props}>
|
||||
<View
|
||||
ref={viewRef}
|
||||
style={[style, paddingStyle]}
|
||||
onLayout={this._onLayout}
|
||||
{...props}>
|
||||
{children}
|
||||
</View>
|
||||
);
|
||||
|
||||
default:
|
||||
return (
|
||||
<View ref={viewRef} onLayout={this._onLayout} style={style} {...props}>
|
||||
<View
|
||||
ref={viewRef}
|
||||
onLayout={this._onLayout}
|
||||
style={style}
|
||||
{...props}>
|
||||
{children}
|
||||
</View>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user