Skip to content

Commit ffb8a9f

Browse files
CRNS-47: Changing PropType of Component type props to ElementType
1 parent da09d00 commit ffb8a9f

File tree

14 files changed

+97
-43
lines changed

14 files changed

+97
-43
lines changed

src/components/Attachment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const Attachment = withMessageContentContext(
8787
*/
8888
AttachmentFileIcon: PropTypes.oneOfType([
8989
PropTypes.node,
90-
PropTypes.func,
90+
PropTypes.elementType,
9191
]),
9292
};
9393
static defaultProps = {

src/components/Channel.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ const Channel = withChatContext(
3838
*
3939
* Defaults to and accepts same props as: [LoadingIndicator](https://getstream.github.io/stream-chat-react-native/#loadingindicator)
4040
*/
41-
LoadingIndicator: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
41+
LoadingIndicator: PropTypes.oneOfType([
42+
PropTypes.node,
43+
PropTypes.elementType,
44+
]),
4245
/**
4346
* Error indicator UI component. This will be shown on the screen if channel query fails.
4447
*
@@ -47,7 +50,7 @@ const Channel = withChatContext(
4750
* */
4851
LoadingErrorIndicator: PropTypes.oneOfType([
4952
PropTypes.node,
50-
PropTypes.func,
53+
PropTypes.elementType,
5154
]),
5255
/**
5356
* Empty state indicator UI component. This will be shown on the screen if channel has no messages.
@@ -57,21 +60,21 @@ const Channel = withChatContext(
5760
* */
5861
EmptyStateIndicator: PropTypes.oneOfType([
5962
PropTypes.node,
60-
PropTypes.func,
63+
PropTypes.elementType,
6164
]),
6265
/**
6366
* Message UI component to display a message in message list.
6467
*
6568
* Available built-in component (also accepts the same props as): [MessageSimple](https://getstream.github.io/stream-chat-react-native/#messagesimple)
6669
*
6770
* */
68-
Message: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
71+
Message: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
6972
/**
7073
* Attachment UI component to display attachment in individual message.
7174
*
7275
* Available built-in component (also accepts the same props as): [Attachment](https://getstream.github.io/stream-chat-react-native/#attachment)
7376
* */
74-
Attachment: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
77+
Attachment: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
7578
};
7679

7780
static defaultProps = {

src/components/ChannelInner.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,23 @@ export class ChannelInner extends PureComponent {
107107
/** Client is passed via the Chat Context */
108108
client: PropTypes.object.isRequired,
109109
/** The loading indicator to use */
110-
LoadingIndicator: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
110+
LoadingIndicator: PropTypes.oneOfType([
111+
PropTypes.node,
112+
PropTypes.elementType,
113+
]),
111114
/** The indicator to use when there is error */
112115
LoadingErrorIndicator: PropTypes.oneOfType([
113116
PropTypes.node,
114-
PropTypes.func,
117+
PropTypes.elementType,
115118
]),
116119
/** The indicator to use when message list is empty */
117-
EmptyStateIndicator: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
120+
EmptyStateIndicator: PropTypes.oneOfType([
121+
PropTypes.node,
122+
PropTypes.elementType,
123+
]),
118124
isOnline: PropTypes.bool,
119-
Message: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
120-
Attachment: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
125+
Message: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
126+
Attachment: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
121127
};
122128

123129
static defaultProps = {

src/components/ChannelList.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,25 @@ const ChannelList = withChatContext(
3131
class ChannelList extends PureComponent {
3232
static propTypes = {
3333
/** The Preview to use, defaults to [ChannelPreviewMessenger](https://getstream.github.io/stream-chat-react-native/#channelpreviewmessenger) */
34-
Preview: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
34+
Preview: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
3535

3636
/** The loading indicator to use */
37-
LoadingIndicator: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
37+
LoadingIndicator: PropTypes.oneOfType([
38+
PropTypes.node,
39+
PropTypes.elementType,
40+
]),
3841
/** The indicator to use when there is error in fetching channels */
3942
LoadingErrorIndicator: PropTypes.oneOfType([
4043
PropTypes.node,
41-
PropTypes.func,
44+
PropTypes.elementType,
4245
]),
4346
/** The indicator to use when channel list is empty */
4447
EmptyStateIndicator: PropTypes.oneOfType([
4548
PropTypes.node,
46-
PropTypes.func,
49+
PropTypes.elementType,
4750
]),
4851

49-
List: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
52+
List: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
5053
onSelect: PropTypes.func,
5154
/**
5255
* Function that overrides default behaviour when new message is received on channel that is not being watched

src/components/ChannelListMessenger.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,21 @@ const ChannelListMessenger = withChatContext(
2727
]).isRequired,
2828
/** UI Component to display individual channel item in list.
2929
* Defaults to [ChannelPreviewMessenger](https://getstream.github.io/stream-chat-react-native/#channelpreviewmessenger) */
30-
Preview: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
30+
Preview: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
3131
/** The loading indicator to use. Default: [LoadingIndicator](https://getstream.github.io/stream-chat-react-native/#loadingindicator) */
32-
LoadingIndicator: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
32+
LoadingIndicator: PropTypes.oneOfType([
33+
PropTypes.node,
34+
PropTypes.elementType,
35+
]),
3336
/** The indicator to use when there is error in fetching channels. Default: [LoadingErrorIndicator](https://getstream.github.io/stream-chat-react-native/#loadingerrorindicator) */
3437
LoadingErrorIndicator: PropTypes.oneOfType([
3538
PropTypes.node,
36-
PropTypes.func,
39+
PropTypes.elementType,
3740
]),
3841
/** The indicator to use when channel list is empty. Default: [EmptyStateIndicator](https://getstream.github.io/stream-chat-react-native/#emptystateindicator) */
3942
EmptyStateIndicator: PropTypes.oneOfType([
4043
PropTypes.node,
41-
PropTypes.func,
44+
PropTypes.elementType,
4245
]),
4346
/** Loads next page of channels in channels object, which is present here as prop */
4447
loadNextPage: PropTypes.func,

src/components/ChannelPreview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ChannelPreview extends PureComponent {
1818
channel: PropTypes.object.isRequired,
1919
client: PropTypes.object.isRequired,
2020
setActiveChannel: PropTypes.func.isRequired,
21-
Preview: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
21+
Preview: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
2222
};
2323

2424
static defaultProps = {

src/components/FileAttachmentGroup.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ export class FileAttachmentGroup extends React.PureComponent {
1818
* Custom UI component for attachment icon for type 'file' attachment.
1919
* Defaults to: https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/FileIcon.js
2020
*/
21-
AttachmentFileIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
21+
AttachmentFileIcon: PropTypes.oneOfType([
22+
PropTypes.node,
23+
PropTypes.elementType,
24+
]),
2225
};
2326

2427
constructor(props) {

src/components/FileUploadPreview.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ export class FileUploadPreview extends React.PureComponent {
3131
* Custom UI component for attachment icon for type 'file' attachment.
3232
* Defaults to and accepts same props as: https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/FileIcon.js
3333
*/
34-
AttachmentFileIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
34+
AttachmentFileIcon: PropTypes.oneOfType([
35+
PropTypes.node,
36+
PropTypes.elementType,
37+
]),
3538
};
3639

3740
static defaultProps = {

src/components/Message.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ const Message = withKeyboardContext(
4242
* Message UI component to display a message in message list.
4343
* Avaialble from [channel context](https://getstream.github.io/stream-chat-react-native/#channelcontext)
4444
* */
45-
Message: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
45+
Message: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
4646
/**
4747
* Attachment UI component to display attachment in individual message.
4848
* Avaialble from [channel context](https://getstream.github.io/stream-chat-react-native/#channelcontext)
4949
* */
50-
Attachment: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
50+
Attachment: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
5151
/**
5252
* Array of allowed actions on message. e.g. ['edit', 'delete', 'mute', 'flag']
5353
* If all the actions need to be disabled, empty array or false should be provided as value of prop.

src/components/MessageInput.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ const MessageInput = withKeyboardContext(
176176
*
177177
* Defaults to and accepts same props as: [SendButton](https://getstream.github.io/stream-chat-react-native/#sendbutton)
178178
* */
179-
SendButton: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
179+
SendButton: PropTypes.oneOfType([
180+
PropTypes.node,
181+
PropTypes.elementType,
182+
]),
180183
/**
181184
* Additional props for underlying TextInput component. These props will be forwarded as it is to TextInput component.
182185
*
@@ -194,7 +197,7 @@ const MessageInput = withKeyboardContext(
194197
*/
195198
AttachmentFileIcon: PropTypes.oneOfType([
196199
PropTypes.node,
197-
PropTypes.func,
200+
PropTypes.elementType,
198201
]),
199202
};
200203

0 commit comments

Comments
 (0)