Skip to content

Commit da09d00

Browse files
CRNS-11: Adding support for additional props to flatlist in MessageList and ChannelList
1 parent 4da5a25 commit da09d00

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
- Changes to add compatibility for Expo 36. Adding [netinfo](https://github.com/react-native-community/react-native-netinfo) as peer dependency - https://github.com/GetStream/stream-chat-react-native/issues/97
88
- Disabling the longpress on image viewer (in Attachment) - https://github.com/GetStream/stream-chat-react-native/issues/100 to avoid freezing of UI.
99
- Fixing broken threads issue
10+
- Support for `additionalFlatListProps` prop in `MessageList` and `ChannelList` component
1011

1112
#### stream-chat-react-native (Native package)
1213

1314
- Disabling the longpress on image viewer (in Attachment) - https://github.com/GetStream/stream-chat-react-native/issues/100 to avoid freezing of UI.
1415
- Fixing broken threads issue
16+
- Support for `additionalFlatListProps` prop in `MessageList` and `ChannelList` component
1517

1618
## [0.4.0] 2019-12-16
1719

src/components/ChannelList.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,21 @@ const ChannelList = withChatContext(
119119
* If true, channels won't be dynamically sorted by most recent message.
120120
*/
121121
lockChannelOrder: PropTypes.bool,
122+
/**
123+
* Besides existing (default) UX behaviour of underlying flatlist of ChannelList component, if you want
124+
* to attach some additional props to un derlying flatlist, you can add it to following prop.
125+
*
126+
* You can find list of all the available FlatList props here - https://facebook.github.io/react-native/docs/flatlist#props
127+
*
128+
* e.g.
129+
* ```
130+
* <ChannelList
131+
* filters={filters}
132+
* sort={sort}
133+
* additionalFlatListProps={{ bounces: true }} />
134+
* ```
135+
*/
136+
additionalFlatListProps: PropTypes.object,
122137
};
123138

124139
static defaultProps = {
@@ -133,6 +148,7 @@ const ChannelList = withChatContext(
133148
// https://github.com/facebook/react-native/blob/a7a7970e543959e9db5281914d5f132beb01db8d/Libraries/Lists/VirtualizedList.js#L466
134149
loadMoreThreshold: 2,
135150
lockChannelOrder: false,
151+
additionalFlatListProps: {},
136152
logger: () => {},
137153
};
138154

src/components/ChannelListMessenger.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ const ChannelListMessenger = withChatContext(
5151
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
5252
/** If channels are being queries. LoadingIndicator will be displayed if true */
5353
loadingChannels: PropTypes.bool,
54+
/**
55+
* Besides existing (default) UX behaviour of underlying flatlist of ChannelListMessenger component, if you want
56+
* to attach some additional props to un derlying flatlist, you can add it to following prop.
57+
*
58+
* You can find list of all the available FlatList props here - https://facebook.github.io/react-native/docs/flatlist#props
59+
*
60+
* e.g.
61+
* ```
62+
* <ChannelListMessenger
63+
* channels={channels}
64+
* additionalFlatListProps={{ bounces: true }} />
65+
* ```
66+
*/
67+
additionalFlatListProps: PropTypes.object,
5468
};
5569

5670
static defaultProps = {
@@ -60,6 +74,7 @@ const ChannelListMessenger = withChatContext(
6074
EmptyStateIndicator,
6175
// https://github.com/facebook/react-native/blob/a7a7970e543959e9db5281914d5f132beb01db8d/Libraries/Lists/VirtualizedList.js#L466
6276
loadMoreThreshold: 2,
77+
additionalFlatListProps: {},
6378
};
6479

6580
renderLoading = () => {
@@ -92,6 +107,7 @@ const ChannelListMessenger = withChatContext(
92107
/>
93108
)}
94109
keyExtractor={(item) => item.cid}
110+
{...this.props.additionalFlatListProps}
95111
/>
96112
);
97113

src/components/MessageList.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,19 @@ const MessageList = withChannelContext(
199199
* Supported styles: https://github.com/beefe/react-native-actionsheet/blob/master/lib/styles.js
200200
*/
201201
actionSheetStyles: PropTypes.object,
202+
/**
203+
* Besides existing (default) UX behaviour of underlying flatlist of MessageList component, if you want
204+
* to attach some additional props to un derlying flatlist, you can add it to following prop.
205+
*
206+
* You can find list of all the available FlatList props here - https://facebook.github.io/react-native/docs/flatlist#props
207+
*
208+
* e.g.
209+
* ```
210+
* <MessageList
211+
* additionalFlatListProps={{ bounces: true, keyboardDismissMode: true }} />
212+
* ```
213+
*/
214+
additionalFlatListProps: PropTypes.object,
202215
};
203216

204217
static defaultProps = {
@@ -208,6 +221,7 @@ const MessageList = withChannelContext(
208221
// https://github.com/facebook/react-native/blob/a7a7970e543959e9db5281914d5f132beb01db8d/Libraries/Lists/VirtualizedList.js#L466
209222
loadMoreThreshold: 2,
210223
messageGrouping: true,
224+
additionalFlatListProps: {},
211225
dismissKeyboardOnMessageTouch: true,
212226
TypingIndicator,
213227
};
@@ -600,6 +614,7 @@ const MessageList = withChannelContext(
600614
minIndexForVisible: 1,
601615
autoscrollToTopThreshold: 10,
602616
}}
617+
{...this.props.additionalFlatListProps}
603618
/>
604619
{this.props.TypingIndicator && showTypingIndicator && (
605620
<TypingIndicatorContainer>

0 commit comments

Comments
 (0)