UIKit React Native v3
UIKit React Native
UIKit
React Native
Home
/
UIKit
/
React Native

SendbirdChatProvider

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

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 state.

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

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

const Component = () => {
    const { sdk, 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>
        </>
    );
};