Skip to content

Commit

Permalink
remove createrReactClass from SizeFlexibilityUpdateTest (facebook#21715)
Browse files Browse the repository at this point in the history
Summary:
Related to facebook#21581 .
Removed createReactClass from the IntegrationTests/SizeFlexibilityUpdateTest.js

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

[GENERAL] [ENHANCEMENT] [IntegrationTests/SizeFlexibilityUpdateTest.js] - remove createReactClass dependency
Pull Request resolved: facebook#21715

Reviewed By: TheSavior

Differential Revision: D10341543

Pulled By: RSNara

fbshipit-source-id: 748f9a0176b6cd865d956df774f6dec1ead21562
  • Loading branch information
nissy-dev authored and facebook-github-bot committed Oct 16, 2018
1 parent bbb477e commit 227079f
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions IntegrationTests/SizeFlexibilityUpdateTest.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');
const {View} = ReactNative;
Expand All @@ -24,29 +23,38 @@ const reactViewHeight = 222;

let finalState = false;

const SizeFlexibilityUpdateTest = createReactClass({
displayName: 'SizeFlexibilityUpdateTest',
_subscription: (null: ?EmitterSubscription),
type Props = $ReadOnly<{|
width: boolean,
height: boolean,
both: boolean,
none: boolean,
|}>;

UNSAFE_componentWillMount: function() {
class SizeFlexibilityUpdateTest extends React.Component<Props> {
_subscription: ?EmitterSubscription = null;

UNSAFE_componentWillMount() {
this._subscription = RCTNativeAppEventEmitter.addListener(
'rootViewDidChangeIntrinsicSize',
this.rootViewDidChangeIntrinsicSize,
);
},
}

componentWillUnmount: function() {
componentWillUnmount() {
if (this._subscription != null) {
this._subscription.remove();
}
},
}

markPassed: function() {
markPassed = () => {
TestModule.markTestPassed(true);
finalState = true;
},
};

rootViewDidChangeIntrinsicSize: function(intrinsicSize) {
rootViewDidChangeIntrinsicSize = (intrinsicSize: {
width: number,
height: number,
}) => {
if (finalState) {
// If a test reaches its final state, it is not expected to do anything more
TestModule.markTestPassed(false);
Expand Down Expand Up @@ -89,13 +97,11 @@ const SizeFlexibilityUpdateTest = createReactClass({
return;
}
}
},
};

render() {
return <View style={{height: reactViewHeight, width: reactViewWidth}} />;
},
});

SizeFlexibilityUpdateTest.displayName = 'SizeFlexibilityUpdateTest';
}
}

module.exports = SizeFlexibilityUpdateTest;

0 comments on commit 227079f

Please sign in to comment.