Skip to content

Commit

Permalink
Replace React.createClass with create-react-class
Browse files Browse the repository at this point in the history
Summary:
This replaces all uses of `React.createClass` with `createReactClass` from the `create-react-class` package, attempting to match use of `var` and `const` according to local style.

Fixes #14620
Refs #14712
Closes #14729

Differential Revision: D5321810

Pulled By: hramos

fbshipit-source-id: ae7b40640b2773fd89c3fb727ec87f688bebf585
  • Loading branch information
mojodna authored and hramos committed Jul 12, 2017
1 parent e76eb32 commit 82fc0f3
Show file tree
Hide file tree
Showing 44 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions IntegrationTests/LayoutEventsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type State = {
};

var LayoutEventsTest = createReactClass({
displayName: 'LayoutEventsTest',
getInitialState(): State {
return {
didAnimation: false,
Expand Down
1 change: 1 addition & 0 deletions IntegrationTests/ReactContentSizeUpdateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var newReactViewWidth = 201;
var newReactViewHeight = 202;

var ReactContentSizeUpdateTest = createReactClass({
displayName: 'ReactContentSizeUpdateTest',
mixins: [Subscribable.Mixin,
TimerMixin],

Expand Down
1 change: 1 addition & 0 deletions IntegrationTests/SizeFlexibilityUpdateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var reactViewHeight = 222;
var finalState = false;

var SizeFlexibilityUpdateTest = createReactClass({
displayName: 'SizeFlexibilityUpdateTest',
mixins: [Subscribable.Mixin],

componentWillMount: function() {
Expand Down
1 change: 1 addition & 0 deletions IntegrationTests/TimersTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var {
var { TestModule } = ReactNative.NativeModules;

var TimersTest = createReactClass({
displayName: 'TimersTest',
mixins: [TimerMixin],

_nextTest: () => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type DefaultProps = {
* Displays a circular loading indicator.
*/
const ActivityIndicator = createReactClass({
displayName: 'ActivityIndicator',
mixins: [NativeMethodsMixin],

propTypes: {
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/DatePicker/DatePickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Event = Object;
*/
// $FlowFixMe(>=0.41.0)
const DatePickerIOS = createReactClass({
displayName: 'DatePickerIOS',
// TOOD: Put a better type for _picker
_picker: (undefined: ?$FlowFixMe),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ var DRAWER_STATES = [
* ```
*/
var DrawerLayoutAndroid = createReactClass({
displayName: 'DrawerLayoutAndroid',
statics: {
positions: DrawerConsts.DrawerPosition,
},
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/Keyboard/KeyboardAvoidingView.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const viewRef = 'VIEW';
*/
// $FlowFixMe(>=0.41.0)
const KeyboardAvoidingView = createReactClass({
displayName: 'KeyboardAvoidingView',
mixins: [TimerMixin],

propTypes: {
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/LazyRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var PropTypes = require('prop-types');
var TimerMixin = require('react-timer-mixin');

var LazyRenderer = createReactClass({
displayName: 'LazyRenderer',
mixin: [TimerMixin],

propTypes: {
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/Navigation/NavigatorIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ type Event = Object;
*
*/
var NavigatorIOS = createReactClass({
displayName: 'NavigatorIOS',

propTypes: {

Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/Picker/PickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var itemStylePropType = StyleSheetPropType(TextStylePropTypes);
var requireNativeComponent = require('requireNativeComponent');

var PickerIOS = createReactClass({
displayName: 'PickerIOS',
mixins: [NativeMethodsMixin],

propTypes: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var indeterminateType = function(props, propName, componentName, ...rest) {
* ```
*/
var ProgressBarAndroid = createReactClass({
displayName: 'ProgressBarAndroid',
propTypes: {
...ViewPropTypes,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var requireNativeComponent = require('requireNativeComponent');
*/
// $FlowFixMe(>=0.41.0)
var ProgressViewIOS = createReactClass({
displayName: 'ProgressViewIOS',
mixins: [NativeMethodsMixin],

propTypes: {
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/RefreshControl/RefreshControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ if (Platform.OS === 'android') {
*/
// $FlowFixMe(>=0.41.0)
const RefreshControl = createReactClass({
displayName: 'RefreshControl',
statics: {
SIZE: RefreshLayoutConsts.SIZE,
},
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const requireNativeComponent = require('requireNativeComponent');
*/
// $FlowFixMe(>=0.41.0)
const ScrollView = createReactClass({
displayName: 'ScrollView',
propTypes: {
...ViewPropTypes,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Event = Object;
*/
// $FlowFixMe(>=0.41.0)
var SegmentedControlIOS = createReactClass({
displayName: 'SegmentedControlIOS',
mixins: [NativeMethodsMixin],

propTypes: {
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Event = Object;
*/
// $FlowFixMe(>=0.41.0)
var Slider = createReactClass({
displayName: 'Slider',
mixins: [NativeMethodsMixin],

propTypes: {
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/Switch/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type DefaultProps = {
*/
// $FlowFixMe(>=0.41.0)
var Switch = createReactClass({
displayName: 'Switch',
propTypes: {
...ViewPropTypes,
/**
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const DataDetectorTypes = [
*/
// $FlowFixMe(>=0.41.0)
const TextInput = createReactClass({
displayName: 'TextInput',
statics: {
/* TODO(brentvatne) docs are needed for this */
State: TextInputState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ var optionalImageSource = PropTypes.oneOfType([
* [0]: https://developer.android.com/reference/android/support/v7/widget/Toolbar.html
*/
var ToolbarAndroid = createReactClass({
displayName: 'ToolbarAndroid',
mixins: [NativeMethodsMixin],

propTypes: {
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/Touchable/TouchableBounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
*/
// $FlowFixMe(>=0.41.0)
var TouchableBounce = createReactClass({
displayName: 'TouchableBounce',
mixins: [Touchable.Mixin, NativeMethodsMixin],

propTypes: {
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/Touchable/TouchableHighlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
*/

var TouchableHighlight = createReactClass({
displayName: 'TouchableHighlight',
propTypes: {
...TouchableWithoutFeedback.propTypes,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
*/

var TouchableNativeFeedback = createReactClass({
displayName: 'TouchableNativeFeedback',
propTypes: {
...TouchableWithoutFeedback.propTypes,

Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/Touchable/TouchableOpacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
* ```
*/
var TouchableOpacity = createReactClass({
displayName: 'TouchableOpacity',
mixins: [TimerMixin, Touchable.Mixin, NativeMethodsMixin],

propTypes: {
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/Touchable/TouchableWithoutFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
*/
// $FlowFixMe(>=0.41.0)
const TouchableWithoutFeedback = createReactClass({
displayName: 'TouchableWithoutFeedback',
mixins: [TimerMixin, Touchable.Mixin],

propTypes: {
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/View/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export type Props = ViewProps;
*/
// $FlowFixMe(>=0.41.0)
const View = createReactClass({
displayName: 'View',
// TODO: We should probably expose the mixins, viewConfig, and statics publicly. For example,
// one of the props is of type AccessibilityComponentType. That is defined as a const[] above,
// but it is not rendered by the docs, since `statics` below is not rendered. So its Possible
Expand Down
1 change: 1 addition & 0 deletions Libraries/Experimental/SwipeableRow/SwipeableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const RIGHT_SWIPE_THRESHOLD = 30 * SLOW_SPEED_SWIPE_FACTOR;
* to use this component separately.
*/
const SwipeableRow = createReactClass({
displayName: 'SwipeableRow',
_panResponder: {},
_previousLeft: CLOSED_LEFT_POSITION,

Expand Down
1 change: 1 addition & 0 deletions Libraries/Image/Image.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ var ViewStyleKeys = new Set(Object.keys(ViewStylePropTypes));
var ImageSpecificStyleKeys = new Set(Object.keys(ImageStylePropTypes).filter(x => !ViewStyleKeys.has(x)));

var Image = createReactClass({
displayName: 'Image',
propTypes: {
...ViewPropTypes,
style: StyleSheetPropType(ImageStylePropTypes),
Expand Down
1 change: 1 addition & 0 deletions Libraries/Image/Image.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const ImageViewManager = NativeModules.ImageViewManager;
*/
// $FlowFixMe(>=0.41.0)
const Image = createReactClass({
displayName: 'Image',
propTypes: {
/**
* > `ImageResizeMode` is an `Enum` for different image resizing modes, set via the
Expand Down
1 change: 1 addition & 0 deletions Libraries/Lists/ListView/ListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ var DEFAULT_SCROLL_CALLBACK_THROTTLE = 50;
*/

var ListView = createReactClass({
displayName: 'ListView',
_childFrames: ([]: Array<Object>),
_sentEndForContentLength: (null: ?number),
_scrollComponent: (null: any),
Expand Down
1 change: 1 addition & 0 deletions Libraries/Text/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const viewConfig = {

// $FlowFixMe(>=0.41.0)
const Text = createReactClass({
displayName: 'Text',
propTypes: {
/**
* When `numberOfLines` is set, this prop defines how text will be truncated.
Expand Down
1 change: 1 addition & 0 deletions Libraries/Text/TextUpdateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var {
var TestManager = NativeModules.TestManager || NativeModules.SnapshotTestManager;

var TextUpdateTest = createReactClass({
displayName: 'TextUpdateTest',
mixins: [TimerMixin],
getInitialState: function() {
return {seeMore: true};
Expand Down
1 change: 1 addition & 0 deletions RNTester/js/CameraRollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ var propTypes = {
};

var CameraRollView = createReactClass({
displayName: 'CameraRollView',
// $FlowFixMe(>=0.41.0)
propTypes: propTypes,

Expand Down
1 change: 1 addition & 0 deletions RNTester/js/ImageExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const IMAGE_PREFETCH_URL = 'http://origami.design/public/images/bird-logo.png?r=
var prefetchTask = Image.prefetch(IMAGE_PREFETCH_URL);

var NetworkImageCallbackExample = createReactClass({
displayName: 'NetworkImageCallbackExample',
getInitialState: function() {
return {
events: [],
Expand Down
1 change: 1 addition & 0 deletions RNTester/js/ListViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var {
var RNTesterPage = require('./RNTesterPage');

var ListViewSimpleExample = createReactClass({
displayName: 'ListViewSimpleExample',
statics: {
title: '<ListView>',
description: 'Performant, scrollable list of data.'
Expand Down
1 change: 1 addition & 0 deletions RNTester/js/ListViewGridLayoutExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var THUMB_URLS = [
];

var ListViewGridLayoutExample = createReactClass({
displayName: 'ListViewGridLayoutExample',

statics: {
title: '<ListView> - Grid Layout',
Expand Down
1 change: 1 addition & 0 deletions RNTester/js/PanResponderExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var {
var CIRCLE_SIZE = 80;

var PanResponderExample = createReactClass({
displayName: 'PanResponderExample',

statics: {
title: 'PanResponder Sample',
Expand Down
1 change: 1 addition & 0 deletions RNTester/js/ProgressBarAndroidExample.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var RNTesterPage = require('RNTesterPage');
var TimerMixin = require('react-timer-mixin');

var MovingBar = createReactClass({
displayName: 'MovingBar',
mixins: [TimerMixin],

getInitialState: function() {
Expand Down
1 change: 1 addition & 0 deletions RNTester/js/ProgressViewIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var {
var TimerMixin = require('react-timer-mixin');

var ProgressViewExample = createReactClass({
displayName: 'ProgressViewExample',
mixins: [TimerMixin],

getInitialState() {
Expand Down
1 change: 1 addition & 0 deletions RNTester/js/SwipeableListViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var {
var RNTesterPage = require('./RNTesterPage');

var SwipeableListViewSimpleExample = createReactClass({
displayName: 'SwipeableListViewSimpleExample',
statics: {
title: '<SwipeableListView>',
description: 'Performant, scrollable, swipeable list of data.'
Expand Down
1 change: 1 addition & 0 deletions RNTester/js/TextExample.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class AttributeToggler extends React.Component {
}

var AdjustingFontSize = createReactClass({
displayName: 'AdjustingFontSize',
getInitialState: function() {
return {dynamicText:'', shouldRender: true,};
},
Expand Down
1 change: 1 addition & 0 deletions RNTester/js/TimerExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class RequestIdleCallbackTester extends React.Component {
}

var TimerTester = createReactClass({
displayName: 'TimerTester',
mixins: [TimerMixin],

_ii: 0,
Expand Down
2 changes: 2 additions & 0 deletions ReactAndroid/src/androidTest/js/ScrollViewTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var onItemPress = function(itemNumber) {
};

var ScrollViewTestApp = createReactClass({
displayName: 'ScrollViewTestApp',
getInitialState: getInitialState,
onScroll: onScroll,
onItemPress: onItemPress,
Expand All @@ -92,6 +93,7 @@ var ScrollViewTestApp = createReactClass({
});

var HorizontalScrollViewTestApp = createReactClass({
displayName: 'HorizontalScrollViewTestApp',
getInitialState: getInitialState,
onScroll: onScroll,
onItemPress: onItemPress,
Expand Down
6 changes: 6 additions & 0 deletions ReactAndroid/src/androidTest/js/UIManagerTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var createReactClass = require('create-react-class');
var renderApplication = require('renderApplication');

var FlexTestApp = createReactClass({
displayName: 'FlexTestApp',
_styles: StyleSheet.create({
container: {
width: 200,
Expand Down Expand Up @@ -49,6 +50,7 @@ var FlexTestApp = createReactClass({
});

var FlexWithText = createReactClass({
displayName: 'FlexWithText',
_styles: StyleSheet.create({
container: {
flexDirection: 'column',
Expand Down Expand Up @@ -77,6 +79,7 @@ var FlexWithText = createReactClass({
});

var AbsolutePositionTestApp = createReactClass({
displayName: 'AbsolutePositionTestApp',
_styles: StyleSheet.create({
absolute: {
position: 'absolute',
Expand All @@ -92,6 +95,7 @@ var AbsolutePositionTestApp = createReactClass({
});

var AbsolutePositionBottomRightTestApp = createReactClass({
displayName: 'AbsolutePositionBottomRightTestApp',
_styles: StyleSheet.create({
container: {
width: 100,
Expand All @@ -115,6 +119,7 @@ var AbsolutePositionBottomRightTestApp = createReactClass({
});

var CenteredTextView = createReactClass({
displayName: 'CenteredTextView',
_styles: StyleSheet.create({
parent: {
width: 200,
Expand All @@ -141,6 +146,7 @@ var CenteredTextView = createReactClass({

var flushUpdatePositionInList = null;
var UpdatePositionInListTestApp = createReactClass({
displayName: 'UpdatePositionInListTestApp',
_styles: StyleSheet.create({
element: {
height: 10,
Expand Down

0 comments on commit 82fc0f3

Please sign in to comment.