stream-chat-react-native-core 6.7.3-beta.1 → 6.7.3-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/lib/commonjs/components/Channel/Channel.js +296 -293
  2. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  3. package/lib/commonjs/components/Channel/hooks/useMessageListPagination.js +133 -147
  4. package/lib/commonjs/components/Channel/hooks/useMessageListPagination.js.map +1 -1
  5. package/lib/commonjs/components/KeyboardCompatibleView/KeyboardCompatibleView.js +7 -12
  6. package/lib/commonjs/components/KeyboardCompatibleView/KeyboardCompatibleView.js.map +1 -1
  7. package/lib/commonjs/components/MessageList/MessageList.js +167 -179
  8. package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
  9. package/lib/commonjs/components/MessageList/hooks/useMessageList.js +60 -37
  10. package/lib/commonjs/components/MessageList/hooks/useMessageList.js.map +1 -1
  11. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +450 -459
  12. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  13. package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
  14. package/lib/commonjs/hooks/index.js +11 -0
  15. package/lib/commonjs/hooks/index.js.map +1 -1
  16. package/lib/commonjs/hooks/useStableCallback.js +13 -0
  17. package/lib/commonjs/hooks/useStableCallback.js.map +1 -0
  18. package/lib/commonjs/version.json +1 -1
  19. package/lib/module/components/Channel/Channel.js +296 -293
  20. package/lib/module/components/Channel/Channel.js.map +1 -1
  21. package/lib/module/components/Channel/hooks/useMessageListPagination.js +133 -147
  22. package/lib/module/components/Channel/hooks/useMessageListPagination.js.map +1 -1
  23. package/lib/module/components/KeyboardCompatibleView/KeyboardCompatibleView.js +7 -12
  24. package/lib/module/components/KeyboardCompatibleView/KeyboardCompatibleView.js.map +1 -1
  25. package/lib/module/components/MessageList/MessageList.js +167 -179
  26. package/lib/module/components/MessageList/MessageList.js.map +1 -1
  27. package/lib/module/components/MessageList/hooks/useMessageList.js +60 -37
  28. package/lib/module/components/MessageList/hooks/useMessageList.js.map +1 -1
  29. package/lib/module/contexts/messageInputContext/MessageInputContext.js +450 -459
  30. package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  31. package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
  32. package/lib/module/hooks/index.js +11 -0
  33. package/lib/module/hooks/index.js.map +1 -1
  34. package/lib/module/hooks/useStableCallback.js +13 -0
  35. package/lib/module/hooks/useStableCallback.js.map +1 -0
  36. package/lib/module/version.json +1 -1
  37. package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
  38. package/lib/typescript/components/Channel/hooks/useMessageListPagination.d.ts +3 -3
  39. package/lib/typescript/components/Channel/hooks/useMessageListPagination.d.ts.map +1 -1
  40. package/lib/typescript/components/KeyboardCompatibleView/KeyboardCompatibleView.d.ts +3 -0
  41. package/lib/typescript/components/KeyboardCompatibleView/KeyboardCompatibleView.d.ts.map +1 -1
  42. package/lib/typescript/components/MessageList/MessageList.d.ts.map +1 -1
  43. package/lib/typescript/components/MessageList/hooks/useMessageList.d.ts +4 -0
  44. package/lib/typescript/components/MessageList/hooks/useMessageList.d.ts.map +1 -1
  45. package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts.map +1 -1
  46. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +1 -1
  47. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts.map +1 -1
  48. package/lib/typescript/hooks/index.d.ts +1 -0
  49. package/lib/typescript/hooks/index.d.ts.map +1 -1
  50. package/lib/typescript/hooks/useStableCallback.d.ts +26 -0
  51. package/lib/typescript/hooks/useStableCallback.d.ts.map +1 -0
  52. package/package.json +1 -1
  53. package/src/components/Channel/Channel.tsx +462 -431
  54. package/src/components/Channel/__tests__/Channel.test.js +8 -3
  55. package/src/components/Channel/hooks/useMessageListPagination.tsx +152 -147
  56. package/src/components/KeyboardCompatibleView/KeyboardCompatibleView.tsx +6 -4
  57. package/src/components/MessageList/MessageList.tsx +147 -112
  58. package/src/components/MessageList/hooks/useMessageList.ts +69 -38
  59. package/src/contexts/messageInputContext/MessageInputContext.tsx +293 -267
  60. package/src/contexts/messageInputContext/__tests__/pickFile.test.tsx +2 -1
  61. package/src/contexts/messagesContext/MessagesContext.tsx +1 -0
  62. package/src/hooks/index.ts +1 -0
  63. package/src/hooks/useStableCallback.ts +37 -0
  64. package/src/version.json +1 -1
@@ -356,7 +356,7 @@ describe('Channel initial load useEffect', () => {
356
356
  cleanup();
357
357
  });
358
358
 
359
- it('should not call channel.watch if channel is not initialized', async () => {
359
+ it('should still call channel.watch if we are online and DB channels are loaded', async () => {
360
360
  const messages = Array.from({ length: 10 }, (_, i) => generateMessage({ id: i }));
361
361
  const mockedChannel = generateChannelResponse({
362
362
  messages,
@@ -366,13 +366,18 @@ describe('Channel initial load useEffect', () => {
366
366
  const channel = chatClient.channel('messaging', mockedChannel.id);
367
367
  await channel.watch();
368
368
  channel.offlineMode = true;
369
- channel.state = channelInitialState;
369
+ channel.state = {
370
+ ...channelInitialState,
371
+ messagePagination: {
372
+ hasPrev: true,
373
+ },
374
+ };
370
375
  const watchSpy = jest.fn();
371
376
  channel.watch = watchSpy;
372
377
 
373
378
  renderComponent({ channel });
374
379
 
375
- await waitFor(() => expect(watchSpy).not.toHaveBeenCalled());
380
+ await waitFor(() => expect(watchSpy).toHaveBeenCalledTimes(1));
376
381
  });
377
382
 
378
383
  it("should call channel.watch if channel is initialized and it's not in offline mode", async () => {
@@ -6,6 +6,7 @@ import { Channel, ChannelState, MessageResponse } from 'stream-chat';
6
6
  import { useChannelMessageDataState } from './useChannelDataState';
7
7
 
8
8
  import { ChannelContextValue } from '../../../contexts/channelContext/ChannelContext';
9
+ import { useStableCallback } from '../../../hooks';
9
10
  import { DefaultStreamChatGenerics } from '../../../types/types';
10
11
  import { findInMessagesByDate, findInMessagesById } from '../../../utils/utils';
11
12
 
@@ -66,7 +67,7 @@ export const useMessageListPagination = <
66
67
  /**
67
68
  * This function loads the latest messages in the channel.
68
69
  */
69
- const loadLatestMessages = async () => {
70
+ const loadLatestMessages = useStableCallback(async () => {
70
71
  try {
71
72
  setLoading(true);
72
73
  await channel.state.loadMessageIntoState('latest');
@@ -75,12 +76,12 @@ export const useMessageListPagination = <
75
76
  } catch (err) {
76
77
  console.warn('Loading latest messages failed with error:', err);
77
78
  }
78
- };
79
+ });
79
80
 
80
81
  /**
81
82
  * This function loads more messages before the first message in current channel state.
82
83
  */
83
- const loadMore = async (limit = 20) => {
84
+ const loadMore = useStableCallback(async (limit: number = 20) => {
84
85
  if (!channel.state.messagePagination.hasPrev) {
85
86
  return;
86
87
  }
@@ -104,12 +105,12 @@ export const useMessageListPagination = <
104
105
  setLoadingMore(false);
105
106
  console.warn('Message pagination(fetching old messages) request failed with error:', e);
106
107
  }
107
- };
108
+ });
108
109
 
109
110
  /**
110
111
  * This function loads more messages after the most recent message in current channel state.
111
112
  */
112
- const loadMoreRecent = async (limit = 10) => {
113
+ const loadMoreRecent = useStableCallback(async (limit: number = 10) => {
113
114
  if (!channel.state.messagePagination.hasNext) {
114
115
  return;
115
116
  }
@@ -133,7 +134,7 @@ export const useMessageListPagination = <
133
134
  console.warn('Message pagination(fetching new messages) request failed with error:', e);
134
135
  return;
135
136
  }
136
- };
137
+ });
137
138
 
138
139
  /**
139
140
  * Loads channel around a specific message
@@ -141,171 +142,175 @@ export const useMessageListPagination = <
141
142
  * @param messageId If undefined, channel will be loaded at most recent message.
142
143
  */
143
144
  const loadChannelAroundMessage: ChannelContextValue<StreamChatGenerics>['loadChannelAroundMessage'] =
144
- async ({ limit = 25, messageId: messageIdToLoadAround, setTargetedMessage }) => {
145
- if (!messageIdToLoadAround) {
146
- return;
147
- }
148
- setLoadingMore(true);
149
- setLoading(true);
150
- try {
151
- await channel.state.loadMessageIntoState(messageIdToLoadAround, undefined, limit);
152
- loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
153
- jumpToMessageFinished(channel.state.messagePagination.hasNext, messageIdToLoadAround);
145
+ useStableCallback(
146
+ async ({ limit = 25, messageId: messageIdToLoadAround, setTargetedMessage }) => {
147
+ if (!messageIdToLoadAround) {
148
+ return;
149
+ }
150
+ setLoadingMore(true);
151
+ setLoading(true);
152
+ try {
153
+ await channel.state.loadMessageIntoState(messageIdToLoadAround, undefined, limit);
154
+ loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
155
+ jumpToMessageFinished(channel.state.messagePagination.hasNext, messageIdToLoadAround);
154
156
 
155
- if (setTargetedMessage) {
156
- setTargetedMessage(messageIdToLoadAround);
157
+ if (setTargetedMessage) {
158
+ setTargetedMessage(messageIdToLoadAround);
159
+ }
160
+ } catch (error) {
161
+ setLoadingMore(false);
162
+ setLoading(false);
163
+ console.warn(
164
+ 'Message pagination(fetching messages in the channel around a message id) request failed with error:',
165
+ error,
166
+ );
167
+ return;
157
168
  }
158
- } catch (error) {
159
- setLoadingMore(false);
160
- setLoading(false);
161
- console.warn(
162
- 'Message pagination(fetching messages in the channel around a message id) request failed with error:',
163
- error,
164
- );
165
- return;
166
- }
167
- };
169
+ },
170
+ );
168
171
 
169
172
  /**
170
173
  * Fetch messages around a specific timestamp.
171
174
  */
172
- const fetchMessagesAround = async <
173
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
174
- >(
175
- channel: Channel<StreamChatGenerics>,
176
- timestamp: string,
177
- limit: number,
178
- ): Promise<MessageResponse<StreamChatGenerics>[]> => {
179
- try {
180
- const { messages } = await channel.query(
181
- { messages: { created_at_around: timestamp, limit } },
182
- 'new',
183
- );
184
- return messages;
185
- } catch (error) {
186
- console.error('Error fetching messages around timestamp:', error);
187
- throw error;
188
- }
189
- };
175
+ const fetchMessagesAround = useStableCallback(
176
+ async <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(
177
+ channel: Channel<StreamChatGenerics>,
178
+ timestamp: string,
179
+ limit: number,
180
+ ): Promise<MessageResponse<StreamChatGenerics>[]> => {
181
+ try {
182
+ const { messages } = await channel.query(
183
+ { messages: { created_at_around: timestamp, limit } },
184
+ 'new',
185
+ );
186
+ return messages;
187
+ } catch (error) {
188
+ console.error('Error fetching messages around timestamp:', error);
189
+ throw error;
190
+ }
191
+ },
192
+ );
190
193
 
191
194
  /**
192
195
  * Loads channel at first unread message.
193
196
  */
194
197
  const loadChannelAtFirstUnreadMessage: ChannelContextValue<StreamChatGenerics>['loadChannelAtFirstUnreadMessage'] =
195
- async ({ channelUnreadState, limit = 25, setChannelUnreadState, setTargetedMessage }) => {
196
- try {
197
- if (!channelUnreadState?.unread_messages) {
198
- return;
199
- }
200
- const { first_unread_message_id, last_read, last_read_message_id } = channelUnreadState;
201
- let firstUnreadMessageId = first_unread_message_id;
202
- let lastReadMessageId = last_read_message_id;
203
- let isInCurrentMessageSet = false;
204
- const messagesState = channel.state.messages;
198
+ useStableCallback(
199
+ async ({ channelUnreadState, limit = 25, setChannelUnreadState, setTargetedMessage }) => {
200
+ try {
201
+ if (!channelUnreadState?.unread_messages) {
202
+ return;
203
+ }
204
+ const { first_unread_message_id, last_read, last_read_message_id } = channelUnreadState;
205
+ let firstUnreadMessageId = first_unread_message_id;
206
+ let lastReadMessageId = last_read_message_id;
207
+ let isInCurrentMessageSet = false;
208
+ const messagesState = channel.state.messages;
205
209
 
206
- // If the first unread message is already in the current message set, we don't need to load more messages.
207
- if (firstUnreadMessageId) {
208
- const messageIdx = findInMessagesById(messagesState, firstUnreadMessageId);
209
- isInCurrentMessageSet = messageIdx !== -1;
210
- }
211
- // If the last read message is already in the current message set, we don't need to load more messages, and we set the first unread message id as that is what we want to operate on.
212
- else if (lastReadMessageId) {
213
- const messageIdx = findInMessagesById(messagesState, lastReadMessageId);
214
- isInCurrentMessageSet = messageIdx !== -1;
215
- firstUnreadMessageId = messageIdx > -1 ? messagesState[messageIdx + 1]?.id : undefined;
216
- } else {
217
- const lastReadTimestamp = last_read.getTime();
218
- const { index: lastReadIdx, message: lastReadMessage } = findInMessagesByDate(
219
- messagesState,
220
- last_read,
221
- );
222
- if (lastReadMessage) {
223
- lastReadMessageId = lastReadMessage.id;
224
- firstUnreadMessageId = messagesState[lastReadIdx + 1].id;
225
- isInCurrentMessageSet = !!firstUnreadMessageId;
210
+ // If the first unread message is already in the current message set, we don't need to load more messages.
211
+ if (firstUnreadMessageId) {
212
+ const messageIdx = findInMessagesById(messagesState, firstUnreadMessageId);
213
+ isInCurrentMessageSet = messageIdx !== -1;
214
+ }
215
+ // If the last read message is already in the current message set, we don't need to load more messages, and we set the first unread message id as that is what we want to operate on.
216
+ else if (lastReadMessageId) {
217
+ const messageIdx = findInMessagesById(messagesState, lastReadMessageId);
218
+ isInCurrentMessageSet = messageIdx !== -1;
219
+ firstUnreadMessageId = messageIdx > -1 ? messagesState[messageIdx + 1]?.id : undefined;
226
220
  } else {
227
- setLoadingMore(true);
228
- setLoading(true);
229
- let messages;
230
- try {
231
- messages = await fetchMessagesAround(channel, last_read.toISOString(), limit);
232
- } catch (error) {
233
- setLoading(false);
234
- loadMoreFinished(channel.state.messagePagination.hasPrev, messagesState);
235
- console.log('Loading channel at first unread message failed with error:', error);
236
- return;
237
- }
221
+ const lastReadTimestamp = last_read.getTime();
222
+ const { index: lastReadIdx, message: lastReadMessage } = findInMessagesByDate(
223
+ messagesState,
224
+ last_read,
225
+ );
226
+ if (lastReadMessage) {
227
+ lastReadMessageId = lastReadMessage.id;
228
+ firstUnreadMessageId = messagesState[lastReadIdx + 1].id;
229
+ isInCurrentMessageSet = !!firstUnreadMessageId;
230
+ } else {
231
+ setLoadingMore(true);
232
+ setLoading(true);
233
+ let messages;
234
+ try {
235
+ messages = await fetchMessagesAround(channel, last_read.toISOString(), limit);
236
+ } catch (error) {
237
+ setLoading(false);
238
+ loadMoreFinished(channel.state.messagePagination.hasPrev, messagesState);
239
+ console.log('Loading channel at first unread message failed with error:', error);
240
+ return;
241
+ }
238
242
 
239
- const firstMessageWithCreationDate = messages.find((msg) => msg.created_at);
240
- if (!firstMessageWithCreationDate) {
241
- loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
242
- throw new Error('Failed to jump to first unread message id.');
243
- }
244
- const firstMessageTimestamp = new Date(
245
- firstMessageWithCreationDate.created_at as string,
246
- ).getTime();
243
+ const firstMessageWithCreationDate = messages.find((msg) => msg.created_at);
244
+ if (!firstMessageWithCreationDate) {
245
+ loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
246
+ throw new Error('Failed to jump to first unread message id.');
247
+ }
248
+ const firstMessageTimestamp = new Date(
249
+ firstMessageWithCreationDate.created_at as string,
250
+ ).getTime();
247
251
 
248
- if (lastReadTimestamp < firstMessageTimestamp) {
249
- // whole channel is unread
250
- firstUnreadMessageId = firstMessageWithCreationDate.id;
251
- } else {
252
- const result = findInMessagesByDate(messages, last_read);
253
- lastReadMessageId = result.message?.id;
252
+ if (lastReadTimestamp < firstMessageTimestamp) {
253
+ // whole channel is unread
254
+ firstUnreadMessageId = firstMessageWithCreationDate.id;
255
+ } else {
256
+ const result = findInMessagesByDate(messages, last_read);
257
+ lastReadMessageId = result.message?.id;
258
+ }
259
+ loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
254
260
  }
255
- loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
256
261
  }
257
- }
258
262
 
259
- // If we still don't have the first and last read message id, we can't proceed.
260
- if (!firstUnreadMessageId && !lastReadMessageId) {
261
- throw new Error('Failed to jump to first unread message id.');
262
- }
263
+ // If we still don't have the first and last read message id, we can't proceed.
264
+ if (!firstUnreadMessageId && !lastReadMessageId) {
265
+ throw new Error('Failed to jump to first unread message id.');
266
+ }
263
267
 
264
- // If the first unread message is not in the current message set, we need to load message around the id.
265
- if (!isInCurrentMessageSet) {
266
- try {
267
- setLoadingMore(true);
268
- setLoading(true);
269
- const targetedMessage = (firstUnreadMessageId || lastReadMessageId) as string;
270
- await channel.state.loadMessageIntoState(targetedMessage, undefined, limit);
271
- /**
272
- * if the index of the last read message on the page is beyond the half of the page,
273
- * we have arrived to the oldest page of the channel
274
- */
275
- const indexOfTarget = channel.state.messages.findIndex(
276
- (message) => message.id === targetedMessage,
277
- );
268
+ // If the first unread message is not in the current message set, we need to load message around the id.
269
+ if (!isInCurrentMessageSet) {
270
+ try {
271
+ setLoadingMore(true);
272
+ setLoading(true);
273
+ const targetedMessage = (firstUnreadMessageId || lastReadMessageId) as string;
274
+ await channel.state.loadMessageIntoState(targetedMessage, undefined, limit);
275
+ /**
276
+ * if the index of the last read message on the page is beyond the half of the page,
277
+ * we have arrived to the oldest page of the channel
278
+ */
279
+ const indexOfTarget = channel.state.messages.findIndex(
280
+ (message) => message.id === targetedMessage,
281
+ );
278
282
 
279
- loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
280
- firstUnreadMessageId =
281
- firstUnreadMessageId ?? channel.state.messages[indexOfTarget + 1].id;
282
- } catch (error) {
283
- setLoading(false);
284
- loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
285
- console.log('Loading channel at first unread message failed with error:', error);
286
- return;
283
+ loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
284
+ firstUnreadMessageId =
285
+ firstUnreadMessageId ?? channel.state.messages[indexOfTarget + 1].id;
286
+ } catch (error) {
287
+ setLoading(false);
288
+ loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
289
+ console.log('Loading channel at first unread message failed with error:', error);
290
+ return;
291
+ }
287
292
  }
288
- }
289
293
 
290
- if (!firstUnreadMessageId) {
291
- throw new Error('Failed to jump to first unread message id.');
292
- }
293
- if (!first_unread_message_id && setChannelUnreadState) {
294
- setChannelUnreadState({
295
- ...channelUnreadState,
296
- first_unread_message_id: firstUnreadMessageId,
297
- last_read_message_id: lastReadMessageId,
298
- });
299
- }
294
+ if (!firstUnreadMessageId) {
295
+ throw new Error('Failed to jump to first unread message id.');
296
+ }
297
+ if (!first_unread_message_id && setChannelUnreadState) {
298
+ setChannelUnreadState({
299
+ ...channelUnreadState,
300
+ first_unread_message_id: firstUnreadMessageId,
301
+ last_read_message_id: lastReadMessageId,
302
+ });
303
+ }
300
304
 
301
- jumpToMessageFinished(channel.state.messagePagination.hasNext, firstUnreadMessageId);
302
- if (setTargetedMessage) {
303
- setTargetedMessage(firstUnreadMessageId);
305
+ jumpToMessageFinished(channel.state.messagePagination.hasNext, firstUnreadMessageId);
306
+ if (setTargetedMessage) {
307
+ setTargetedMessage(firstUnreadMessageId);
308
+ }
309
+ } catch (error) {
310
+ console.log('Loading channel at first unread message failed with error:', error);
304
311
  }
305
- } catch (error) {
306
- console.log('Loading channel at first unread message failed with error:', error);
307
- }
308
- };
312
+ },
313
+ );
309
314
 
310
315
  return {
311
316
  copyMessagesStateFromChannel,
@@ -197,6 +197,8 @@ export class KeyboardCompatibleView extends React.Component<
197
197
  this.unsetKeyboardListeners();
198
198
  }
199
199
 
200
+ keyboardContextValue = { dismissKeyboard: this.dismissKeyboard };
201
+
200
202
  render() {
201
203
  const { behavior, children, contentContainerStyle, enabled, style, ...props } = this.props;
202
204
  const bottomHeight = enabled ? this.state.bottom : 0;
@@ -215,7 +217,7 @@ export class KeyboardCompatibleView extends React.Component<
215
217
  };
216
218
  }
217
219
  return (
218
- <KeyboardProvider value={{ dismissKeyboard: this.dismissKeyboard }}>
220
+ <KeyboardProvider value={this.keyboardContextValue}>
219
221
  <View
220
222
  onLayout={this._onLayout}
221
223
  ref={this.viewRef}
@@ -229,7 +231,7 @@ export class KeyboardCompatibleView extends React.Component<
229
231
 
230
232
  case 'position':
231
233
  return (
232
- <KeyboardProvider value={{ dismissKeyboard: this.dismissKeyboard }}>
234
+ <KeyboardProvider value={this.keyboardContextValue}>
233
235
  <View onLayout={this._onLayout} ref={this.viewRef} style={style} {...props}>
234
236
  <View
235
237
  style={StyleSheet.compose(contentContainerStyle, {
@@ -244,7 +246,7 @@ export class KeyboardCompatibleView extends React.Component<
244
246
 
245
247
  case 'padding':
246
248
  return (
247
- <KeyboardProvider value={{ dismissKeyboard: this.dismissKeyboard }}>
249
+ <KeyboardProvider value={this.keyboardContextValue}>
248
250
  <View
249
251
  onLayout={this._onLayout}
250
252
  ref={this.viewRef}
@@ -258,7 +260,7 @@ export class KeyboardCompatibleView extends React.Component<
258
260
 
259
261
  default:
260
262
  return (
261
- <KeyboardProvider value={{ dismissKeyboard: this.dismissKeyboard }}>
263
+ <KeyboardProvider value={this.keyboardContextValue}>
262
264
  <View onLayout={this._onLayout} ref={this.viewRef} style={style} {...props}>
263
265
  {children}
264
266
  </View>