Chat UIKit React Native v3
Chat UIKit React Native
Chat UIKit
React Native
Version 3

SendbirdChatProvider

Copy link

The SendbirdChatProvider component is a provider within SendbirdUIKitContainer that passes down the following context properties from the Chat SDK to the child components.

List of context properties

Copy link
PropertyTypeDescription

sdk

SendbirdChatSDK

Specifies the Sendbird Chat SDK instance.

currentUser

SendbirdUser

Specifies the online state of the current user.

updateCurrentUserInfo

(nickname, profile) => Promise<SendbirdUser>

Updates a user's nickname and profile image with URL or file as well as the current user's online status.

See the code below on how to pass down the context properties from the Chat SDK to the child components.

import { useConnection, useSendbirdChat } from '@sendbird/uikit-react-native';
import { Button, Text } from '@sendbird/uikit-react-native-foundation';

const Component = () => {
    const { currentUser, updateCurrentUserInfo } = useSendbirdChat();
    const { connect, disconnect } = useConnection();

    if (!currentUser) {
        return <Button onPress={() => connect('USER_ID', { nickname: 'NICKNAME' })}>{'Connect'}</Button>;
    }

    return (
        <>
            <Text>{currentUser.nickname}</Text>
            <Button onPress={() => updateCurrentUserInfo('UPDATED_NICKNAME')}>{'Update nickname'}</Button>
            <Button onPress={() => disconnect()}>{'Disconnect'}</Button>
        </>
    );
};