Skip to content

Commit

Permalink
Migrate from deprecated React.PropTypes to prop-types (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsabransky authored and cooperka committed Jul 16, 2017
1 parent 632c456 commit b6e98c4
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 127 deletions.
9 changes: 5 additions & 4 deletions example/CustomActions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {
Modal,
Expand Down Expand Up @@ -182,7 +183,7 @@ const styles = StyleSheet.create({
});

CustomActions.contextTypes = {
actionSheet: React.PropTypes.func,
actionSheet: PropTypes.func,
};

CustomActions.defaultProps = {
Expand All @@ -195,9 +196,9 @@ CustomActions.defaultProps = {
};

CustomActions.propTypes = {
onSend: React.PropTypes.func,
options: React.PropTypes.object,
icon: React.PropTypes.func,
onSend: PropTypes.func,
options: PropTypes.object,
icon: PropTypes.func,
containerStyle: ViewPropTypes.style,
wrapperStyle: ViewPropTypes.style,
iconTextStyle: Text.propTypes.style,
Expand Down
3 changes: 2 additions & 1 deletion example/CustomView.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {
Linking,
Expand Down Expand Up @@ -61,7 +62,7 @@ CustomView.defaultProps = {
};

CustomView.propTypes = {
currentMessage: React.PropTypes.object,
currentMessage: PropTypes.object,
containerStyle: ViewPropTypes.style,
mapViewStyle: ViewPropTypes.style,
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@expo/react-native-action-sheet": "cribspot/react-native-action-sheet#b422c54f26d30b9e85eb14a882ea9cec38600730",
"md5": "2.2.1",
"moment": "2.18.1",
"prop-types": "^15.5.10",
"react-native-communications": "2.2.1",
"react-native-invertible-scroll-view": "1.0.0",
"react-native-lightbox": "oblador/react-native-lightbox#c84a8543d4511fe6a44c3d7820747c9c1bddd875",
Expand Down
13 changes: 7 additions & 6 deletions src/Actions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {
StyleSheet,
Expand Down Expand Up @@ -87,7 +88,7 @@ const styles = StyleSheet.create({
});

Actions.contextTypes = {
actionSheet: React.PropTypes.func,
actionSheet: PropTypes.func,
};

Actions.defaultProps = {
Expand All @@ -100,11 +101,11 @@ Actions.defaultProps = {
};

Actions.propTypes = {
onSend: React.PropTypes.func,
options: React.PropTypes.object,
optionTintColor: React.PropTypes.string,
icon: React.PropTypes.func,
onPressActionButton: React.PropTypes.func,
onSend: PropTypes.func,
options: PropTypes.object,
optionTintColor: PropTypes.string,
icon: PropTypes.func,
onPressActionButton: PropTypes.func,
containerStyle: ViewPropTypes.style,
iconTextStyle: Text.propTypes.style,
};
21 changes: 11 additions & 10 deletions src/Avatar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from "react";
import {Image, StyleSheet, View, ViewPropTypes} from "react-native";
import GiftedAvatar from "./GiftedAvatar";
Expand Down Expand Up @@ -36,7 +37,7 @@ export default class Avatar extends React.Component {
</View>
);
}

return (
<View
style={[styles[this.props.position].container, styles[this.props.position][computedStyle], this.props.containerStyle[this.props.position]]}>
Expand Down Expand Up @@ -92,20 +93,20 @@ Avatar.defaultProps = {
};

Avatar.propTypes = {
renderAvatarOnTop: React.PropTypes.bool,
position: React.PropTypes.oneOf(['left', 'right']),
currentMessage: React.PropTypes.object,
nextMessage: React.PropTypes.object,
onPressAvatar: React.PropTypes.func,
containerStyle: React.PropTypes.shape({
renderAvatarOnTop: PropTypes.bool,
position: PropTypes.oneOf(['left', 'right']),
currentMessage: PropTypes.object,
nextMessage: PropTypes.object,
onPressAvatar: PropTypes.func,
containerStyle: PropTypes.shape({
left: ViewPropTypes.style,
right: ViewPropTypes.style,
}),
imageStyle: React.PropTypes.shape({
imageStyle: PropTypes.shape({
left: ViewPropTypes.style,
right: ViewPropTypes.style,
}),
//TODO: remove in next major release
isSameDay: React.PropTypes.func,
isSameUser: React.PropTypes.func
isSameDay: PropTypes.func,
isSameUser: PropTypes.func
};
37 changes: 19 additions & 18 deletions src/Bubble.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {
Text,
Expand Down Expand Up @@ -197,7 +198,7 @@ const styles = {
};

Bubble.contextTypes = {
actionSheet: React.PropTypes.func,
actionSheet: PropTypes.func,
};

Bubble.defaultProps = {
Expand Down Expand Up @@ -227,38 +228,38 @@ Bubble.defaultProps = {
};

Bubble.propTypes = {
touchableProps: React.PropTypes.object,
onLongPress: React.PropTypes.func,
renderMessageImage: React.PropTypes.func,
renderMessageText: React.PropTypes.func,
renderCustomView: React.PropTypes.func,
renderTime: React.PropTypes.func,
position: React.PropTypes.oneOf(['left', 'right']),
currentMessage: React.PropTypes.object,
nextMessage: React.PropTypes.object,
previousMessage: React.PropTypes.object,
containerStyle: React.PropTypes.shape({
touchableProps: PropTypes.object,
onLongPress: PropTypes.func,
renderMessageImage: PropTypes.func,
renderMessageText: PropTypes.func,
renderCustomView: PropTypes.func,
renderTime: PropTypes.func,
position: PropTypes.oneOf(['left', 'right']),
currentMessage: PropTypes.object,
nextMessage: PropTypes.object,
previousMessage: PropTypes.object,
containerStyle: PropTypes.shape({
left: ViewPropTypes.style,
right: ViewPropTypes.style,
}),
wrapperStyle: React.PropTypes.shape({
wrapperStyle: PropTypes.shape({
left: ViewPropTypes.style,
right: ViewPropTypes.style,
}),
bottomContainerStyle: React.PropTypes.shape({
bottomContainerStyle: PropTypes.shape({
left: ViewPropTypes.style,
right: ViewPropTypes.style,
}),
tickStyle: Text.propTypes.style,
containerToNextStyle: React.PropTypes.shape({
containerToNextStyle: PropTypes.shape({
left: ViewPropTypes.style,
right: ViewPropTypes.style,
}),
containerToPreviousStyle: React.PropTypes.shape({
containerToPreviousStyle: PropTypes.shape({
left: ViewPropTypes.style,
right: ViewPropTypes.style,
}),
//TODO: remove in next major release
isSameDay: React.PropTypes.func,
isSameUser: React.PropTypes.func,
isSameDay: PropTypes.func,
isSameUser: PropTypes.func,
};
19 changes: 10 additions & 9 deletions src/Composer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {
Platform,
Expand Down Expand Up @@ -80,14 +81,14 @@ Composer.defaultProps = {
};

Composer.propTypes = {
onChange: React.PropTypes.func,
composerHeight: React.PropTypes.number,
text: React.PropTypes.string,
placeholder: React.PropTypes.string,
placeholderTextColor: React.PropTypes.string,
textInputProps: React.PropTypes.object,
onTextChanged: React.PropTypes.func,
onInputSizeChanged: React.PropTypes.func,
multiline: React.PropTypes.bool,
onChange: PropTypes.func,
composerHeight: PropTypes.number,
text: PropTypes.string,
placeholder: PropTypes.string,
placeholderTextColor: PropTypes.string,
textInputProps: PropTypes.object,
onTextChanged: PropTypes.func,
onInputSizeChanged: PropTypes.func,
multiline: PropTypes.bool,
textInputStyle: TextInput.propTypes.style,
};
11 changes: 6 additions & 5 deletions src/Day.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {
StyleSheet,
Expand Down Expand Up @@ -51,7 +52,7 @@ const styles = StyleSheet.create({
});

Day.contextTypes = {
getLocale: React.PropTypes.func,
getLocale: PropTypes.func,
};

Day.defaultProps = {
Expand All @@ -69,12 +70,12 @@ Day.defaultProps = {
};

Day.propTypes = {
currentMessage: React.PropTypes.object,
previousMessage: React.PropTypes.object,
currentMessage: PropTypes.object,
previousMessage: PropTypes.object,
containerStyle: ViewPropTypes.style,
wrapperStyle: ViewPropTypes.style,
textStyle: Text.propTypes.style,
//TODO: remove in next major release
isSameDay: React.PropTypes.func,
isSameUser: React.PropTypes.func,
isSameDay: PropTypes.func,
isSameUser: PropTypes.func,
};
5 changes: 3 additions & 2 deletions src/GiftedAvatar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
** This component will be published in a separate package
*/
import PropTypes from 'prop-types';
import React from 'react';
import {
Image,
Expand Down Expand Up @@ -154,8 +155,8 @@ GiftedAvatar.defaultProps = {
};

GiftedAvatar.propTypes = {
user: React.PropTypes.object,
onPress: React.PropTypes.func,
user: PropTypes.object,
onPress: PropTypes.func,
avatarStyle: Image.propTypes.style,
textStyle: Text.propTypes.style,
};
65 changes: 33 additions & 32 deletions src/GiftedChat.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {
Animated,
Expand Down Expand Up @@ -468,8 +469,8 @@ const styles = StyleSheet.create({
});

GiftedChat.childContextTypes = {
actionSheet: React.PropTypes.func,
getLocale: React.PropTypes.func,
actionSheet: PropTypes.func,
getLocale: PropTypes.func,
};

GiftedChat.defaultProps = {
Expand Down Expand Up @@ -514,36 +515,36 @@ GiftedChat.defaultProps = {
};

GiftedChat.propTypes = {
messages: React.PropTypes.array,
onSend: React.PropTypes.func,
onInputTextChanged: React.PropTypes.func,
loadEarlier: React.PropTypes.bool,
onLoadEarlier: React.PropTypes.func,
locale: React.PropTypes.string,
isAnimated: React.PropTypes.bool,
renderAccessory: React.PropTypes.func,
renderActions: React.PropTypes.func,
renderAvatar: React.PropTypes.func,
renderBubble: React.PropTypes.func,
renderFooter: React.PropTypes.func,
renderChatFooter: React.PropTypes.func,
renderMessageText: React.PropTypes.func,
renderMessageImage: React.PropTypes.func,
renderComposer: React.PropTypes.func,
renderCustomView: React.PropTypes.func,
renderDay: React.PropTypes.func,
renderInputToolbar: React.PropTypes.func,
renderLoadEarlier: React.PropTypes.func,
renderLoading: React.PropTypes.func,
renderMessage: React.PropTypes.func,
renderSend: React.PropTypes.func,
renderTime: React.PropTypes.func,
user: React.PropTypes.object,
bottomOffset: React.PropTypes.number,
minInputToolbarHeight: React.PropTypes.number,
isLoadingEarlier: React.PropTypes.bool,
messageIdGenerator: React.PropTypes.func,
keyboardShouldPersistTaps: React.PropTypes.oneOf(['always', 'never', 'handled']),
messages: PropTypes.array,
onSend: PropTypes.func,
onInputTextChanged: PropTypes.func,
loadEarlier: PropTypes.bool,
onLoadEarlier: PropTypes.func,
locale: PropTypes.string,
isAnimated: PropTypes.bool,
renderAccessory: PropTypes.func,
renderActions: PropTypes.func,
renderAvatar: PropTypes.func,
renderBubble: PropTypes.func,
renderFooter: PropTypes.func,
renderChatFooter: PropTypes.func,
renderMessageText: PropTypes.func,
renderMessageImage: PropTypes.func,
renderComposer: PropTypes.func,
renderCustomView: PropTypes.func,
renderDay: PropTypes.func,
renderInputToolbar: PropTypes.func,
renderLoadEarlier: PropTypes.func,
renderLoading: PropTypes.func,
renderMessage: PropTypes.func,
renderSend: PropTypes.func,
renderTime: PropTypes.func,
user: PropTypes.object,
bottomOffset: PropTypes.number,
minInputToolbarHeight: PropTypes.number,
isLoadingEarlier: PropTypes.bool,
messageIdGenerator: PropTypes.func,
keyboardShouldPersistTaps: PropTypes.oneOf(['always', 'never', 'handled']),
};

export {
Expand Down
11 changes: 6 additions & 5 deletions src/InputToolbar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {
StyleSheet,
Expand Down Expand Up @@ -89,11 +90,11 @@ InputToolbar.defaultProps = {
};

InputToolbar.propTypes = {
renderAccessory: React.PropTypes.func,
renderActions: React.PropTypes.func,
renderSend: React.PropTypes.func,
renderComposer: React.PropTypes.func,
onPressActionButton: React.PropTypes.func,
renderAccessory: PropTypes.func,
renderActions: PropTypes.func,
renderSend: PropTypes.func,
renderComposer: PropTypes.func,
onPressActionButton: PropTypes.func,
containerStyle: ViewPropTypes.style,
primaryStyle: ViewPropTypes.style,
accessoryStyle: ViewPropTypes.style,
Expand Down
7 changes: 4 additions & 3 deletions src/LoadEarlier.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React from 'react';
import {
ActivityIndicator,
Expand Down Expand Up @@ -92,9 +93,9 @@ LoadEarlier.defaultProps = {
};

LoadEarlier.propTypes = {
onLoadEarlier: React.PropTypes.func,
isLoadingEarlier: React.PropTypes.bool,
label: React.PropTypes.string,
onLoadEarlier: PropTypes.func,
isLoadingEarlier: PropTypes.bool,
label: PropTypes.string,
containerStyle: ViewPropTypes.style,
wrapperStyle: ViewPropTypes.style,
textStyle: Text.propTypes.style,
Expand Down
Loading

0 comments on commit b6e98c4

Please sign in to comment.