From 91471e4df343c793327819b8f84f886c3d770318 Mon Sep 17 00:00:00 2001 From: Himanshu Soni Date: Wed, 10 Oct 2018 14:06:01 -0700 Subject: [PATCH] remove createReactClass from RNTester/js/ProgressViewIOSExample.js (#21611) Summary: Related to #21581 . Removed createReactClass from the RNTester/js/ProgressViewIOSExample.js Test Plan ---------- - [x] npm run prettier - [x] npm run flow-check-ios - [x] npm run flow-check-android - [x] Run RNTester app, go to ProgressViewIOS component, everything works. Release Notes -------------- [GENERAL] [ENHANCEMENT] [RNTester/js/ProgressViewIOSExample.js] - remove createReactClass dependency Pull Request resolved: https://github.com/facebook/react-native/pull/21611 Reviewed By: TheSavior Differential Revision: D10304566 Pulled By: RSNara fbshipit-source-id: 98a9dc83a0517a2866c4174ae254e1a9d9785b87 --- js/ProgressViewIOSExample.js | 41 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/js/ProgressViewIOSExample.js b/js/ProgressViewIOSExample.js index 2d431281a3a..7c6ebfe6c2a 100644 --- a/js/ProgressViewIOSExample.js +++ b/js/ProgressViewIOSExample.js @@ -10,41 +10,42 @@ 'use strict'; -var React = require('react'); -var createReactClass = require('create-react-class'); -var ReactNative = require('react-native'); -var {ProgressViewIOS, StyleSheet, View} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {ProgressViewIOS, StyleSheet, View} = ReactNative; -var ProgressViewExample = createReactClass({ - displayName: 'ProgressViewExample', - _rafId: (null: ?AnimationFrameID), +type Props = {||}; +type State = {| + progress: number, +|}; - getInitialState() { - return { - progress: 0, - }; - }, +class ProgressViewExample extends React.Component { + _rafId: ?AnimationFrameID = null; + + state = { + progress: 0, + }; componentDidMount() { this.updateProgress(); - }, + } componentWillUnmount() { if (this._rafId != null) { cancelAnimationFrame(this._rafId); } - }, + } - updateProgress() { + updateProgress = () => { var progress = this.state.progress + 0.01; this.setState({progress}); this._rafId = requestAnimationFrame(() => this.updateProgress()); - }, + }; - getProgress(offset) { + getProgress = offset => { var progress = this.state.progress + offset; return Math.sin(progress % Math.PI) % 1; - }, + }; render() { return ( @@ -75,8 +76,8 @@ var ProgressViewExample = createReactClass({ /> ); - }, -}); + } +} exports.displayName = (undefined: ?string); exports.framework = 'React';