Skip to content

Commit

Permalink
Migrate React PropTypes to prop-types
Browse files Browse the repository at this point in the history
  • Loading branch information
Željko Rumenjak committed Aug 14, 2017
1 parent 4594bd6 commit 09483bf
Show file tree
Hide file tree
Showing 39 changed files with 153 additions and 125 deletions.
21 changes: 11 additions & 10 deletions components/DropDownMenu/DropDownModal.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, {
Component,
} from 'react';
Expand Down Expand Up @@ -31,45 +32,45 @@ class DropDownModal extends Component {
/**
* Callback that is called when dropdown option is selected
*/
onOptionSelected: React.PropTypes.func,
onOptionSelected: PropTypes.func,
/**
* Collection of objects which will be shown as options in DropDownMenu
*/
options: React.PropTypes.array.isRequired,
options: PropTypes.array.isRequired,
/**
* Selected option that will be shown.
*/
selectedOption: React.PropTypes.any.isRequired,
selectedOption: PropTypes.any.isRequired,
/**
* Key name that represents option's string value,
* and it will be displayed to the user in the UI
*/
titleProperty: React.PropTypes.string.isRequired,
titleProperty: PropTypes.string.isRequired,
/**
* Key name that represents option's value
*/
valueProperty: React.PropTypes.string.isRequired,
valueProperty: PropTypes.string.isRequired,
/**
* Number of options shown without scroll.
* Can be set trough DropDown style.visibleOptions.
* Prop definition overrides style.
*/
visibleOptions: React.PropTypes.number,
visibleOptions: PropTypes.number,
/**
* Optional render function, for every item in the list.
* Input parameter should be shaped as one of the items from the
* options object
*/
renderOption: React.PropTypes.func,
renderOption: PropTypes.func,
/**
* Visibility flag, controling the modal visibility
*/
visible: React.PropTypes.bool,
visible: PropTypes.bool,
/**
* Callback that is called when modal should be closed
*/
onClose: React.PropTypes.func,
style: React.PropTypes.object,
onClose: PropTypes.func,
style: PropTypes.object,
};

static defaultProps = {
Expand Down
3 changes: 2 additions & 1 deletion components/GridRow.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, { Children } from 'react';
import { View as RNView } from 'react-native';
import _ from 'lodash';
Expand Down Expand Up @@ -35,7 +36,7 @@ class GridRow extends React.Component {
}

GridRow.propTypes = {
columns: React.PropTypes.number.isRequired,
columns: PropTypes.number.isRequired,
...RNView.propTypes,
};

Expand Down
6 changes: 2 additions & 4 deletions components/HorizontalPager/HorizontalPager.js
@@ -1,7 +1,5 @@
import React, {
Component,
PropTypes,
} from 'react';
import PropTypes from 'prop-types';
import React, { Component } from 'react';

import {
ScrollView,
Expand Down
9 changes: 5 additions & 4 deletions components/HorizontalPager/Page.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';

import { View } from '../../index';
Expand All @@ -9,10 +10,10 @@ import { View } from '../../index';
*/
export class Page extends Component {
static propTypes = {
isActive: React.PropTypes.bool.isRequired,
width: React.PropTypes.number.isRequired,
style: React.PropTypes.object,
children: React.PropTypes.node,
isActive: PropTypes.bool.isRequired,
width: PropTypes.number.isRequired,
style: PropTypes.object,
children: PropTypes.node,
};

shouldComponentUpdate(nextProps) {
Expand Down
3 changes: 2 additions & 1 deletion components/ImageGallery/ImageGalleryBase.js
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react';
import PropTypes from 'prop-types';
import React, { Component } from 'react';

import _ from 'lodash';

Expand Down
7 changes: 4 additions & 3 deletions components/ImageGalleryOverlay.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import {
ScrollView,
Expand All @@ -23,9 +24,9 @@ const DESCRIPTION_LENGTH_TRIM_LIMIT = 90;
*/
class ImageGalleryOverlay extends Component {
static propTypes = {
title: React.PropTypes.string,
description: React.PropTypes.string,
style: React.PropTypes.object,
title: PropTypes.string,
description: PropTypes.string,
style: PropTypes.object,
};

constructor(props) {
Expand Down
6 changes: 2 additions & 4 deletions components/ImagePreview.js
@@ -1,7 +1,5 @@
import React, {
PropTypes,
Component,
} from 'react';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import {
View,
Modal,
Expand Down
7 changes: 4 additions & 3 deletions components/InlineGallery.js
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react';
import PropTypes from 'prop-types';
import React, { Component } from 'react';

import _ from 'lodash';
import { connectStyle } from '@shoutem/theme';
Expand All @@ -14,8 +15,8 @@ class InlineGallery extends Component {
// Array containing objects with image data (shape defined below)
data: PropTypes.arrayOf(
PropTypes.shape({
source: React.PropTypes.shape({
uri: React.PropTypes.string,
source: PropTypes.shape({
uri: PropTypes.string,
}),
}),
).isRequired,
Expand Down
25 changes: 13 additions & 12 deletions components/ListView.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {
View,
Expand Down Expand Up @@ -65,18 +66,18 @@ class ListDataSource {

class ListView extends React.Component {
static propTypes = {
autoHideHeader: React.PropTypes.bool,
style: React.PropTypes.object,
data: React.PropTypes.array,
loading: React.PropTypes.bool,
onLoadMore: React.PropTypes.func,
onRefresh: React.PropTypes.func,
getSectionId: React.PropTypes.func,
renderRow: React.PropTypes.func,
renderHeader: React.PropTypes.func,
renderFooter: React.PropTypes.func,
renderSectionHeader: React.PropTypes.func,
scrollDriver: React.PropTypes.object,
autoHideHeader: PropTypes.bool,
style: PropTypes.object,
data: PropTypes.array,
loading: PropTypes.bool,
onLoadMore: PropTypes.func,
onRefresh: PropTypes.func,
getSectionId: PropTypes.func,
renderRow: PropTypes.func,
renderHeader: PropTypes.func,
renderFooter: PropTypes.func,
renderSectionHeader: PropTypes.func,
scrollDriver: PropTypes.object,
// TODO(Braco) - add render separator
};

Expand Down
11 changes: 6 additions & 5 deletions components/NavigationBar/NavigationBar.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import {
StatusBar,
Expand Down Expand Up @@ -55,11 +56,11 @@ function setStatusBarStyle(backgroundColor) {
// eslint-disable-next-line react/prefer-stateless-function
class NavigationBar extends Component {
static propTypes = {
leftComponent: React.PropTypes.node,
centerComponent: React.PropTypes.node,
rightComponent: React.PropTypes.node,
style: React.PropTypes.object,
id: React.PropTypes.string,
leftComponent: PropTypes.node,
centerComponent: PropTypes.node,
rightComponent: PropTypes.node,
style: PropTypes.object,
id: PropTypes.string,
};

static defaultProps = {
Expand Down
6 changes: 2 additions & 4 deletions components/PageIndicators.js
@@ -1,7 +1,5 @@
import React, {
Component,
PropTypes,
} from 'react';
import PropTypes from 'prop-types';
import React, { Component } from 'react';

import { connectStyle } from '@shoutem/theme';
import { View } from './View';
Expand Down
3 changes: 2 additions & 1 deletion components/RichMedia.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import { Html } from '../html';

Expand All @@ -7,5 +8,5 @@ export default function RichMedia({ body }) {
}

RichMedia.propTypes = {
body: React.PropTypes.string.isRequired,
body: PropTypes.string.isRequired,
};
5 changes: 3 additions & 2 deletions components/ScrollView/ScrollDriverProvider.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, { Component, Children } from 'react';
import { DriverShape, ScrollDriver } from '@shoutem/animation';
import * as _ from 'lodash';
Expand All @@ -9,7 +10,7 @@ import * as _ from 'lodash';
*/
export class ScrollDriverProvider extends Component {
static childContextTypes = {
driverProvider: React.PropTypes.object,
driverProvider: PropTypes.object,
animationDriver: DriverShape,
};

Expand All @@ -18,7 +19,7 @@ export class ScrollDriverProvider extends Component {
};

static propTypes = {
children: React.PropTypes.node,
children: PropTypes.node,
driver: DriverShape,
};

Expand Down
3 changes: 2 additions & 1 deletion components/ScrollView/ScrollView.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { Animated } from 'react-native';
import { connectStyle } from '@shoutem/theme';
Expand All @@ -14,7 +15,7 @@ class ScrollView extends Component {

static contextTypes = {
animationDriver: DriverShape,
driverProvider: React.PropTypes.object,
driverProvider: PropTypes.object,
};

static childContextTypes = {
Expand Down
3 changes: 2 additions & 1 deletion components/ShareButton.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, {
Component,
} from 'react';
Expand All @@ -9,7 +10,7 @@ import { connectStyle } from '@shoutem/theme';
import { Button } from './Button';
import { Icon } from './Icon';

const { string } = React.PropTypes;
const { string } = PropTypes;

/**
* The ShareButton is a virtual component that wraps a button with a share icon.
Expand Down
3 changes: 2 additions & 1 deletion components/Spinner.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {
ActivityIndicator,
Expand All @@ -24,7 +25,7 @@ class Spinner extends React.Component {
}

Spinner.propTypes = {
style: React.PropTypes.object,
style: PropTypes.object,
};

const StyledSpinner = connectStyle('shoutem.ui.Spinner', {
Expand Down
3 changes: 2 additions & 1 deletion components/Switch.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, {
Component,
} from 'react';
Expand All @@ -9,7 +10,7 @@ import { View } from '@shoutem/ui';
import { connectStyle } from '@shoutem/theme';
import { connectAnimation, TimingDriver } from '@shoutem/animation';

const { bool, func, object, shape } = React.PropTypes;
const { bool, func, object, shape } = PropTypes;

class Switch extends Component {
static propTypes = {
Expand Down
3 changes: 2 additions & 1 deletion components/TextInput.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { TextInput as RNTextInput } from 'react-native';

Expand Down Expand Up @@ -28,7 +29,7 @@ class TextInput extends Component {

TextInput.propTypes = {
...RNTextInput.propTypes,
style: React.PropTypes.object,
style: PropTypes.object,
};

const AnimatedTextInput = connectAnimation(TextInput);
Expand Down
3 changes: 2 additions & 1 deletion components/Touchable.js
@@ -1,4 +1,5 @@
import React, { PropTypes } from 'react';
import PropTypes from 'prop-types';
import React from 'react';
import { Platform } from 'react-native';

import { connectStyle } from '@shoutem/theme';
Expand Down
3 changes: 2 additions & 1 deletion components/TouchableNativeFeedback.js
@@ -1,4 +1,5 @@
import React, { PropTypes } from 'react';
import PropTypes from 'prop-types';
import React from 'react';
import { TouchableNativeFeedback as RNTouchableNativeFeedback } from 'react-native';

import { connectStyle } from '@shoutem/theme';
Expand Down
5 changes: 2 additions & 3 deletions components/Video/Video.js
@@ -1,6 +1,5 @@
import React, {
PropTypes,
} from 'react';
import PropTypes from 'prop-types';
import React from 'react';

import {
View,
Expand Down
3 changes: 2 additions & 1 deletion components/View.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { View as RNView } from 'react-native';

Expand Down Expand Up @@ -35,7 +36,7 @@ class View extends Component {

View.propTypes = {
...RNView.propTypes,
style: React.PropTypes.object,
style: PropTypes.object,
};

const AnimatedView = connectAnimation(View);
Expand Down
7 changes: 4 additions & 3 deletions examples/RestaurantsApp/app/App.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';

Expand All @@ -12,9 +13,9 @@ import RestaurantDetails from './RestaurantDetails';

class App extends Component {
static propTypes = {
onNavigateBack: React.PropTypes.func.isRequired,
navigationState: React.PropTypes.object,
scene: React.PropTypes.object,
onNavigateBack: PropTypes.func.isRequired,
navigationState: PropTypes.object,
scene: PropTypes.object,
};

constructor(props) {
Expand Down
3 changes: 2 additions & 1 deletion examples/RestaurantsApp/app/RestaurantDetails.js
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import {
ScrollView,
Expand All @@ -19,7 +20,7 @@ import {

export default class RestaurantDetails extends Component {
static propTypes = {
restaurant: React.PropTypes.object,
restaurant: PropTypes.object,
};

render() {
Expand Down

0 comments on commit 09483bf

Please sign in to comment.