Skip to content

Commit 4673f21

Browse files
authored
Merge pull request #1484 from GetStream/mads/remove-message-context-error
fix: remove error thrown in useMessageContext
2 parents accd0fa + 9748074 commit 4673f21

File tree

2 files changed

+0
-12
lines changed

2 files changed

+0
-12
lines changed

package/src/contexts/__tests__/index.test.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
useChannelsContext,
1010
useChatContext,
1111
useImageGalleryContext,
12-
useMessageContext,
1312
useMessageOverlayContext,
1413
useMessagesContext,
1514
useOverlayContext,
@@ -75,10 +74,6 @@ describe('contexts hooks in a component throws an error with message when not wr
7574
useImageGalleryContext,
7675
`The useImageGalleryContext hook was called outside the ImageGalleryContext Provider. Make sure you have configured OverlayProvider component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#overlay-provider`,
7776
],
78-
[
79-
useMessageContext,
80-
`The useMessageContext hook was called outside of the MessageContext provider. Make sure you have configured MessageList component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#message-list`,
81-
],
8277
[
8378
useMessageOverlayContext,
8479
`The useMessageOverlayContext hook was called outside the MessageOverlayContext Provider. Make sure you have configured OverlayProvider component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#overlay-provider`,

package/src/contexts/messageContext/MessageContext.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';
1414
import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';
1515

1616
import { getDisplayName } from '../utils/getDisplayName';
17-
import { isTestEnvironment } from '../utils/isTestEnvironment';
1817

1918
export type Alignment = 'right' | 'left';
2019

@@ -129,12 +128,6 @@ export const useMessageContext = <
129128
MessageContext,
130129
) as unknown as MessageContextValue<StreamChatGenerics>;
131130

132-
if (contextValue === DEFAULT_BASE_CONTEXT_VALUE && !isTestEnvironment()) {
133-
throw new Error(
134-
`The useMessageContext hook was called outside of the MessageContext provider. Make sure you have configured MessageList component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#message-list`,
135-
);
136-
}
137-
138131
return contextValue;
139132
};
140133

0 commit comments

Comments
 (0)