From 96bdfe3a6036d2393a61e46c2478bb6cb56cf4e5 Mon Sep 17 00:00:00 2001 From: nd-02110114 Date: Wed, 10 Oct 2018 14:34:00 -0700 Subject: [PATCH] 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 --- .../ReactContentSizeUpdateTest.js | 63 ++++++++++--------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/IntegrationTests/ReactContentSizeUpdateTest.js b/IntegrationTests/ReactContentSizeUpdateTest.js index 8aea15c2b6b..707abc6cb72 100644 --- a/IntegrationTests/ReactContentSizeUpdateTest.js +++ b/IntegrationTests/ReactContentSizeUpdateTest.js @@ -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 { + _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 ( ); - }, -}); - -ReactContentSizeUpdateTest.displayName = 'ReactContentSizeUpdateTest'; + } +} module.exports = ReactContentSizeUpdateTest;