Skip to content

Commit 687f33d

Browse files
committed
fix: remove error thrown in useMessageContext
This error is intended to give users a hint when using a context outside of its provider. However, the MessageContext specifically is something we use ourselves in the Reply component, as well as multiple child components of it, both as part of the MessageList (within Message context) and in the MessageInput component (outside Message context). I've considered two approaches: 1. Removing the error - the idea being that the probable value of it is low enough in this context for it not to catch any possible bugs for any users 2. Creating a secondary `useMessageContextDangerously` or something along those lines for use in the specific case of the MessageInput component. Alternative 2 works, but seems unneccessary/redundant. However, I am open for input/other ideas on this.
1 parent accd0fa commit 687f33d

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

package/src/contexts/messageContext/MessageContext.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,6 @@ export const useMessageContext = <
129129
MessageContext,
130130
) as unknown as MessageContextValue<StreamChatGenerics>;
131131

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-
138132
return contextValue;
139133
};
140134

0 commit comments

Comments
 (0)