Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[createReactClass] remove createrReactClass from SizeFlexibilityUpdateTest #21715

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;