useHuddle01
Once done, initialize your project by calling the initialize()
method and pass projectId
in params.
This method should be invoked first at all times
Name | Type | Description |
---|---|---|
initialize(projectId: string) | Function | initializes and sets up the app state required by the library. |
isInitialized | boolean | state for whether the app is initialized |
me | object | Contains current user's `role`, `displayName`, `meId`, and `avatarUrl`. |
roomState | `IDLE` | `INIT` | `LOBBY` | `ROOM` | States the current state of the room |
Sample Code
import {View, Text, Image} from 'react-native';
import { useHuddle01 } from '@huddle01/react-native';
const App = () => {
const { initialize, isInitialized, me, roomState } = useHuddle01();
useEffect(() => {
// its preferable to use env vars to store projectId
initialize('YOUR_PROJECT_ID');
}, []);
return (
<View>
{isInitialized ? <Text>'Hello World!' </Text>: <Text>'Please initialize'</Text>}
<Text> Room State: {roomState} </Text>
<Image source={{uri: me.avatarUrl}} />
<Text> displayName: {me.displayName} </Text>
<Text> Role: {me.role} </Text>
<Text> Peer ID: {me.meId} </Text>
</View>;
};