Skip to content

Commit

Permalink
remove createReactClass from the IntegrationTests/ReactContentSizeUpd…
Browse files Browse the repository at this point in the history
…ateTest.js (facebook#21622)

Summary:
Related to facebook#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: facebook#21622

Reviewed By: TheSavior

Differential Revision: D10302181

Pulled By: RSNara

fbshipit-source-id: 97b955070deb7a244f335ad609f26ffc07578c01
  • Loading branch information
nissy-dev authored and facebook-github-bot committed Oct 10, 2018
1 parent e4064bd commit e0517b4
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions IntegrationTests/ReactContentSizeUpdateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -25,64 +24,66 @@ 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);
}

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;

0 comments on commit e0517b4

Please sign in to comment.