Skip to content

Commit 104461b

Browse files
CRNS-48: Adding props for thread customization
1 parent f6b2a87 commit 104461b

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/components/Thread.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const NewThreadText = styled.Text`
2828
* The thread is only used for the list of replies to a message.
2929
*
3030
* Thread is a consumer of [channel context](https://getstream.github.io/stream-chat-react-native/#channelcontext)
31+
* Underlying MessageList, MessageInput and Message components can be customized using props:
32+
* - additionalParentMessageProps
33+
* - additionalMessageListProps
34+
* - additionalMessageInputProps
3135
*
3236
* @example ./docs/Thread.md
3337
* @extends Component
@@ -71,6 +75,21 @@ const Thread = withChannelContext(
7175
* **Available from [channel context](https://getstream.github.io/stream-chat-react-native/#channelcontext)**
7276
* If the thread is currently loading more messages. This is helpful to display a loading indicator on threadlist */
7377
threadLoadingMore: PropTypes.bool,
78+
/**
79+
* Additional props for underlying Message component of parent message at the top.
80+
* Available props - https://getstream.github.io/stream-chat-react-native/#message
81+
* */
82+
additionalParentMessageProps: PropTypes.object,
83+
/**
84+
* Additional props for underlying MessageList component.
85+
* Available props - https://getstream.github.io/stream-chat-react-native/#messagelist
86+
* */
87+
additionalMessageListProps: PropTypes.object,
88+
/**
89+
* Additional props for underlying MessageInput component.
90+
* Available props - https://getstream.github.io/stream-chat-react-native/#messageinput
91+
* */
92+
additionalMessageInputProps: PropTypes.object,
7493
};
7594

7695
static defaultProps = {
@@ -131,7 +150,9 @@ class ThreadInner extends React.PureComponent {
131150
readOnly
132151
groupStyles={['single']}
133152
Message={this.props.Message}
153+
// TODO: remove the following line in next release, since we already have additionalParentMessageProps now.
134154
{...this.props}
155+
{...this.props.additionalParentMessageProps}
135156
/>
136157
<NewThread>
137158
<NewThreadText>Start of a new thread</NewThreadText>
@@ -150,8 +171,13 @@ class ThreadInner extends React.PureComponent {
150171
hasMore={this.props.threadHasMore}
151172
loadingMore={this.props.threadLoadingMore}
152173
Message={this.props.Message}
174+
{...this.props.additionalMessageListProps}
175+
/>
176+
<MessageInput
177+
parent={this.props.thread}
178+
focus={this.props.autoFocus}
179+
{...this.props.additionalMessageInputProps}
153180
/>
154-
<MessageInput parent={this.props.thread} focus={this.props.autoFocus} />
155181
</React.Fragment>
156182
);
157183
}

types/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ interface ThreadProps extends ChannelContextValue {
408408
threadMessages?: Client.MessageResponse[];
409409
/** Make input focus on mounting thread */
410410
autoFocus?: boolean;
411+
additionalParentMessageProps?: object;
412+
additionalMessageListProps?: object;
413+
additionalMessageInputProps?: object;
411414
}
412415

413416
interface TypingIndicatorProps {

0 commit comments

Comments
 (0)