Skip to content

Commit 0a57723

Browse files
committed
chore: added warning message to UserProfileContext
1 parent 9084f8d commit 0a57723

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/uikit-react-native/src/contexts/UserProfileCtx.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ type Props = React.PropsWithChildren<{
2929
onBeforeCreateChannel?: OnBeforeCreateChannel;
3030
}>;
3131

32+
let WARN_onCreateChannel = false;
33+
3234
export const UserProfileContext = React.createContext<UserProfileContextType | null>(null);
3335
export const UserProfileProvider = ({ children, onCreateChannel, onBeforeCreateChannel = PASS }: Props) => {
3436
const chatContext = useContext(SendbirdChatContext);
@@ -37,6 +39,13 @@ export const UserProfileProvider = ({ children, onCreateChannel, onBeforeCreateC
3739
if (!chatContext) throw new Error('SendbirdChatContext is not provided');
3840
if (!localizationContext) throw new Error('LocalizationContext is not provided');
3941

42+
if (__DEV__ && !WARN_onCreateChannel && !onCreateChannel) {
43+
Logger.warn(
44+
'You should pass `userProfile.onCreateChannel` prop to SendbirdUIKitContainer if want to use message in a user profile',
45+
);
46+
WARN_onCreateChannel = true;
47+
}
48+
4049
const { bottom, left, right } = useSafeAreaInsets();
4150

4251
const [user, setUser] = useState<SendbirdUser | SendbirdMember>();

0 commit comments

Comments
 (0)