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 facebook-github-bot committed Jul 7, 2017
1 parent 20224b7 commit 9afb71f
Show file tree
Hide file tree
Showing 47 changed files with 150 additions and 56 deletions.
4 changes: 3 additions & 1 deletion IntegrationTests/LayoutEventsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'use strict';

var React = require('react');
var createReactClass = require('create-react-class');
var ReactNative = require('react-native');
var {
Image,
Expand Down Expand Up @@ -58,7 +59,8 @@ type State = {
containerStyle?: Style,
};

var LayoutEventsTest = React.createClass({
var LayoutEventsTest = createReactClass({
displayName: 'LayoutEventsTest',
getInitialState(): State {
return {
didAnimation: false,
Expand Down
4 changes: 3 additions & 1 deletion IntegrationTests/ReactContentSizeUpdateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'use strict';

var React = require('react');
var createReactClass = require('create-react-class');
var ReactNative = require('react-native');
var RCTNativeAppEventEmitter = require('RCTNativeAppEventEmitter');
var Subscribable = require('Subscribable');
Expand All @@ -24,7 +25,8 @@ var reactViewHeight = 102;
var newReactViewWidth = 201;
var newReactViewHeight = 202;

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

Expand Down
4 changes: 3 additions & 1 deletion IntegrationTests/SizeFlexibilityUpdateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'use strict';

var React = require('react');
var createReactClass = require('create-react-class');
var ReactNative = require('react-native');
var RCTNativeAppEventEmitter = require('RCTNativeAppEventEmitter');
var Subscribable = require('Subscribable');
Expand All @@ -22,7 +23,8 @@ var reactViewHeight = 222;

var finalState = false;

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

componentWillMount: function() {
Expand Down
4 changes: 3 additions & 1 deletion IntegrationTests/TimersTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'use strict';

var React = require('react');
var createReactClass = require('create-react-class');
var ReactNative = require('react-native');
var TimerMixin = require('react-timer-mixin');

Expand All @@ -22,7 +23,8 @@ var {
} = ReactNative;
var { TestModule } = ReactNative.NativeModules;

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

_nextTest: () => {},
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/ActivityIndicator/ActivityIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const StyleSheet = require('StyleSheet');
const View = require('View');
const ViewPropTypes = require('ViewPropTypes');

const createReactClass = require('create-react-class');
const requireNativeComponent = require('requireNativeComponent');

const GRAY = '#999999';
Expand All @@ -36,7 +37,8 @@ type DefaultProps = {
/**
* Displays a circular loading indicator.
*/
const ActivityIndicator = React.createClass({
const ActivityIndicator = createReactClass({
displayName: 'ActivityIndicator',
mixins: [NativeMethodsMixin],

propTypes: {
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/DatePicker/DatePickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const StyleSheet = require('StyleSheet');
const View = require('View');
const ViewPropTypes = require('ViewPropTypes');

const createReactClass = require('create-react-class');
const requireNativeComponent = require('requireNativeComponent');

type DefaultProps = {
Expand All @@ -36,7 +37,8 @@ type Event = Object;
* source of truth.
*/
// $FlowFixMe(>=0.41.0)
const DatePickerIOS = React.createClass({
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 @@ -24,6 +24,7 @@ var ViewPropTypes = require('ViewPropTypes');

var DrawerConsts = UIManager.AndroidDrawerLayout.Constants;

var createReactClass = require('create-react-class');
var dismissKeyboard = require('dismissKeyboard');
var requireNativeComponent = require('requireNativeComponent');

Expand Down Expand Up @@ -67,7 +68,8 @@ var DRAWER_STATES = [
* },
* ```
*/
var DrawerLayoutAndroid = React.createClass({
var DrawerLayoutAndroid = createReactClass({
displayName: 'DrawerLayoutAndroid',
statics: {
positions: DrawerConsts.DrawerPosition,
},
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/Keyboard/KeyboardAvoidingView.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
'use strict';

const createReactClass = require('create-react-class');
const Keyboard = require('Keyboard');
const LayoutAnimation = require('LayoutAnimation');
const Platform = require('Platform');
Expand Down Expand Up @@ -43,7 +44,8 @@ const viewRef = 'VIEW';
* It can automatically adjust either its position or bottom padding based on the position of the keyboard.
*/
// $FlowFixMe(>=0.41.0)
const KeyboardAvoidingView = React.createClass({
const KeyboardAvoidingView = createReactClass({
displayName: 'KeyboardAvoidingView',
mixins: [TimerMixin],

propTypes: {
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/LazyRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
'use strict';

var React = require('React');
var createReactClass = require('create-react-class');
var PropTypes = require('prop-types');
var TimerMixin = require('react-timer-mixin');

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

propTypes: {
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/Navigation/NavigatorIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var TVEventHandler = require('TVEventHandler');
var View = require('View');
var ViewPropTypes = require('ViewPropTypes');

var createReactClass = require('create-react-class');
var invariant = require('fbjs/lib/invariant');
var logError = require('logError');
var requireNativeComponent = require('requireNativeComponent');
Expand Down Expand Up @@ -304,7 +305,8 @@ type Event = Object;
* is pushed.
*
*/
var NavigatorIOS = React.createClass({
var NavigatorIOS = createReactClass({
displayName: 'NavigatorIOS',

propTypes: {

Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/Picker/PickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ var View = require('View');
const ViewPropTypes = require('ViewPropTypes');
var processColor = require('processColor');

var createReactClass = require('create-react-class');
var itemStylePropType = StyleSheetPropType(TextStylePropTypes);
var requireNativeComponent = require('requireNativeComponent');

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

propTypes: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var PropTypes = require('prop-types');
var ViewPropTypes = require('ViewPropTypes');
var ColorPropType = require('ColorPropType');

var createReactClass = require('create-react-class');
var requireNativeComponent = require('requireNativeComponent');

var STYLE_ATTRIBUTES = [
Expand Down Expand Up @@ -63,7 +64,8 @@ var indeterminateType = function(props, propName, componentName, ...rest) {
* },
* ```
*/
var ProgressBarAndroid = React.createClass({
var ProgressBarAndroid = createReactClass({
displayName: 'ProgressBarAndroid',
propTypes: {
...ViewPropTypes,
/**
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ var PropTypes = require('prop-types');
var StyleSheet = require('StyleSheet');
var ViewPropTypes = require('ViewPropTypes');

var createReactClass = require('create-react-class');
var requireNativeComponent = require('requireNativeComponent');

/**
* Use `ProgressViewIOS` to render a UIProgressView on iOS.
*/
// $FlowFixMe(>=0.41.0)
var ProgressViewIOS = React.createClass({
var ProgressViewIOS = createReactClass({
displayName: 'ProgressViewIOS',
mixins: [NativeMethodsMixin],

propTypes: {
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/RefreshControl/RefreshControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const React = require('React');
const PropTypes = require('prop-types');
const ViewPropTypes = require('ViewPropTypes');

const createReactClass = require('create-react-class');
const requireNativeComponent = require('requireNativeComponent');

if (Platform.OS === 'android') {
Expand Down Expand Up @@ -72,7 +73,8 @@ if (Platform.OS === 'android') {
* in the `onRefresh` function otherwise the refresh indicator will stop immediately.
*/
// $FlowFixMe(>=0.41.0)
const RefreshControl = React.createClass({
const RefreshControl = createReactClass({
displayName: 'RefreshControl',
statics: {
SIZE: RefreshLayoutConsts.SIZE,
},
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const View = require('View');
const ViewPropTypes = require('ViewPropTypes');
const ViewStylePropTypes = require('ViewStylePropTypes');

const createReactClass = require('create-react-class');
const dismissKeyboard = require('dismissKeyboard');
const flattenStyle = require('flattenStyle');
const invariant = require('fbjs/lib/invariant');
Expand Down Expand Up @@ -72,7 +73,8 @@ import type {NativeMethodsMixinType} from 'ReactNativeTypes';
* supports out of the box.
*/
// $FlowFixMe(>=0.41.0)
const ScrollView = React.createClass({
const ScrollView = createReactClass({
displayName: 'ScrollView',
propTypes: {
...ViewPropTypes,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var PropTypes = require('prop-types');
var StyleSheet = require('StyleSheet');
var ViewPropTypes = require('ViewPropTypes');

var createReactClass = require('create-react-class');
var requireNativeComponent = require('requireNativeComponent');

type DefaultProps = {
Expand Down Expand Up @@ -49,7 +50,8 @@ type Event = Object;
* ````
*/
// $FlowFixMe(>=0.41.0)
var SegmentedControlIOS = React.createClass({
var SegmentedControlIOS = createReactClass({
displayName: 'SegmentedControlIOS',
mixins: [NativeMethodsMixin],

propTypes: {
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var PropTypes = require('prop-types');
var StyleSheet = require('StyleSheet');
var ViewPropTypes = require('ViewPropTypes');

var createReactClass = require('create-react-class');
var requireNativeComponent = require('requireNativeComponent');

type Event = Object;
Expand All @@ -29,7 +30,8 @@ type Event = Object;
* A component used to select a single value from a range of values.
*/
// $FlowFixMe(>=0.41.0)
var Slider = React.createClass({
var Slider = createReactClass({
displayName: 'Slider',
mixins: [NativeMethodsMixin],

propTypes: {
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/Switch/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const PropTypes = require('prop-types');
var StyleSheet = require('StyleSheet');
const ViewPropTypes = require('ViewPropTypes');

var createReactClass = require('create-react-class');
var requireNativeComponent = require('requireNativeComponent');

type DefaultProps = {
Expand All @@ -38,7 +39,8 @@ type DefaultProps = {
* @keyword toggle
*/
// $FlowFixMe(>=0.41.0)
var Switch = React.createClass({
var Switch = createReactClass({
displayName: 'Switch',
propTypes: {
...ViewPropTypes,
/**
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const EventEmitter = require('EventEmitter');
const NativeMethodsMixin = require('NativeMethodsMixin');
const Platform = require('Platform');
const React = require('React');
const createReactClass = require('create-react-class');
const PropTypes = require('prop-types');
const ReactNative = require('ReactNative');
const StyleSheet = require('StyleSheet');
Expand Down Expand Up @@ -168,7 +169,8 @@ const DataDetectorTypes = [
*
*/
// $FlowFixMe(>=0.41.0)
const TextInput = React.createClass({
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 @@ -20,6 +20,7 @@ var UIManager = require('UIManager');
var ViewPropTypes = require('ViewPropTypes');
var ColorPropType = require('ColorPropType');

var createReactClass = require('create-react-class');
var requireNativeComponent = require('requireNativeComponent');
var resolveAssetSource = require('resolveAssetSource');

Expand Down Expand Up @@ -65,7 +66,8 @@ var optionalImageSource = PropTypes.oneOfType([
*
* [0]: https://developer.android.com/reference/android/support/v7/widget/Toolbar.html
*/
var ToolbarAndroid = React.createClass({
var ToolbarAndroid = createReactClass({
displayName: 'ToolbarAndroid',
mixins: [NativeMethodsMixin],

propTypes: {
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/Touchable/TouchableBounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var Animated = require('Animated');
var EdgeInsetsPropType = require('EdgeInsetsPropType');
var NativeMethodsMixin = require('NativeMethodsMixin');
var React = require('React');
var createReactClass = require('create-react-class');
var PropTypes = require('prop-types');
var Touchable = require('Touchable');

Expand All @@ -35,7 +36,8 @@ var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
* interesting interactions such as `handleTouchablePress`.
*/
// $FlowFixMe(>=0.41.0)
var TouchableBounce = React.createClass({
var TouchableBounce = createReactClass({
displayName: 'TouchableBounce',
mixins: [Touchable.Mixin, NativeMethodsMixin],

propTypes: {
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/Touchable/TouchableHighlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var TouchableWithoutFeedback = require('TouchableWithoutFeedback');
var View = require('View');
const ViewPropTypes = require('ViewPropTypes');

var createReactClass = require('create-react-class');
var ensureComponentIsNative = require('ensureComponentIsNative');
var ensurePositiveDelayProps = require('ensurePositiveDelayProps');
var keyOf = require('fbjs/lib/keyOf');
Expand Down Expand Up @@ -68,7 +69,8 @@ var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
* ```
*/

var TouchableHighlight = React.createClass({
var TouchableHighlight = createReactClass({
displayName: 'TouchableHighlight',
propTypes: {
...TouchableWithoutFeedback.propTypes,
/**
Expand Down
Loading

0 comments on commit 9afb71f

Please sign in to comment.