remove createReactClass from the IntegrationTests/ReactContentSizeUpdateTest.js (#21622)

Summary:
Related to #21581 .
Removed createReactClass from the IntegrationTests/ReactContentSizeUpdateTest.js

 - [x] npm run prettier
 - [x] npm run flow-check-ios
 - [x] npm run flow-check-android

[GENERAL] [ENHANCEMENT] [IntegrationTests/ReactContentSizeUpdateTest.js] - remove createReactClass dependency
Pull Request resolved: https://github.com/facebook/react-native/pull/21622

Reviewed By: TheSavior

Differential Revision: D10302181

Pulled By: RSNara

fbshipit-source-id: 97b955070deb7a244f335ad609f26ffc07578c01
This commit is contained in:
nd-02110114
2018-10-10 14:34:00 -07:00
committed by Facebook Github Bot
parent a7f958376b
commit 96bdfe3a60

View File

@@ -11,7 +11,6 @@
'use strict';
const React = require('react');
const createReactClass = require('create-react-class');
const ReactNative = require('react-native');
const RCTNativeAppEventEmitter = require('RCTNativeAppEventEmitter');
@@ -25,39 +24,36 @@ const reactViewHeight = 102;
const newReactViewWidth = 201;
const newReactViewHeight = 202;
const ReactContentSizeUpdateTest = createReactClass({
displayName: 'ReactContentSizeUpdateTest',
_timeoutID: (null: ?TimeoutID),
_subscription: (null: ?EmitterSubscription),
type Props = {||};
UNSAFE_componentWillMount: function() {
type State = {|
height: number,
width: number,
|};
class ReactContentSizeUpdateTest extends React.Component<Props, State> {
_timeoutID: ?TimeoutID = null;
_subscription: ?EmitterSubscription = null;
state = {
height: reactViewHeight,
width: reactViewWidth,
};
UNSAFE_componentWillMount() {
this._subscription = RCTNativeAppEventEmitter.addListener(
'rootViewDidChangeIntrinsicSize',
this.rootViewDidChangeIntrinsicSize,
);
},
}
getInitialState: function() {
return {
height: reactViewHeight,
width: reactViewWidth,
};
},
updateViewSize: function() {
this.setState({
height: newReactViewHeight,
width: newReactViewWidth,
});
},
componentDidMount: function() {
componentDidMount() {
this._timeoutID = setTimeout(() => {
this.updateViewSize();
}, 1000);
},
}
componentWillUnmount: function() {
componentWillUnmount() {
if (this._timeoutID != null) {
clearTimeout(this._timeoutID);
}
@@ -65,24 +61,29 @@ const ReactContentSizeUpdateTest = createReactClass({
if (this._subscription != null) {
this._subscription.remove();
}
},
}
rootViewDidChangeIntrinsicSize: function(intrinsicSize) {
updateViewSize() {
this.setState({
height: newReactViewHeight,
width: newReactViewWidth,
});
}
rootViewDidChangeIntrinsicSize = (intrinsicSize: State) => {
if (
intrinsicSize.height === newReactViewHeight &&
intrinsicSize.width === newReactViewWidth
) {
TestModule.markTestPassed(true);
}
},
};
render() {
return (
<View style={{height: this.state.height, width: this.state.width}} />
);
},
});
ReactContentSizeUpdateTest.displayName = 'ReactContentSizeUpdateTest';
}
}
module.exports = ReactContentSizeUpdateTest;