CoHostModal - Co-host assignment and responsibility management interface

CoHostModal is a React Native component that provides host users with controls to assign a co-host from participant list and configure their responsibilities (media management, participant management, settings access). Changes are broadcast in real-time via Socket.io.

Key Features:

  • Co-host participant selection from dropdown
  • Granular responsibility toggles (manage media, manage participants, manage settings)
  • Real-time updates via Socket.io
  • Current co-host display
  • Validation and error alerts
  • Position-configurable modal (4 corners)
  • Scrollable responsibility list

UI Customization: This component can be replaced via uiOverrides.coHostModal to provide a completely custom co-host management interface.

// Basic usage with participant selection
import React, { useState } from 'react';
import { CoHostModal } from 'mediasfu-reactnative-expo';
import { io } from 'socket.io-client';

const socket = io('https://your-server.com');
const [showCoHost, setShowCoHost] = useState(false);

const participants = [
{ name: 'John Doe', islevel: '1', id: '123' },
{ name: 'Jane Smith', islevel: '2', id: '456' },
];

const responsibilities = [
{ name: 'manageParticipants', value: true, dedicated: false },
{ name: 'manageMedia', value: false, dedicated: true },
{ name: 'manageSettings', value: true, dedicated: false },
];

return (
<CoHostModal
isCoHostModalVisible={showCoHost}
onCoHostClose={() => setShowCoHost(false)}
currentCohost="John Doe"
participants={participants}
coHostResponsibility={responsibilities}
roomName="meeting-room-123"
socket={socket}
updateCoHost={(name) => console.log('New co-host:', name)}
updateCoHostResponsibility={(resp) => console.log('Updated:', resp)}
updateIsCoHostModalVisible={setShowCoHost}
showAlert={({ message, type }) => alert(message)}
/>
);
// With custom positioning and alert handling
const handleModifySettings = (settings: ModifyCoHostSettingsOptions) => {
modifyCoHostSettings(settings);
console.log('Co-host settings applied');
};

return (
<CoHostModal
isCoHostModalVisible={isVisible}
onCoHostClose={handleClose}
onModifyEventSettings={handleModifySettings}
currentCohost={currentCoHost}
participants={participantList}
coHostResponsibility={coHostResponsibilities}
roomName={roomId}
socket={socketInstance}
updateCoHost={setCurrentCoHost}
updateCoHostResponsibility={setCoHostResponsibilities}
updateIsCoHostModalVisible={setIsVisible}
position="bottomRight"
backgroundColor="#2c3e50"
showAlert={showCustomAlert}
/>
);
// Using custom UI via uiOverrides
const config = {
uiOverrides: {
coHostModal: {
component: MyCustomCoHostManager,
injectedProps: {
theme: 'dark',
allowMultipleCoHosts: false,
},
},
},
};

return <MyMeetingComponent config={config} />;

Properties

propTypes?: WeakValidationMap<CoHostModalOptions>

Used to declare the types of the props accepted by the component. These types will be checked during rendering and in development only.

We recommend using TypeScript instead of checking prop types at runtime.

contextTypes?: ValidationMap<any>

Lets you specify which legacy context is consumed by this component.

defaultProps?: Partial<CoHostModalOptions>

Used to define default values for the props accepted by the component.

type Props = { name?: string }

const MyComponent: FC<Props> = (props) => {
return <div>{props.name}</div>
}

MyComponent.defaultProps = {
name: 'John Doe'
}
displayName?: string

Used in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.


const MyComponent: FC = () => {
return <div>Hello!</div>
}

MyComponent.displayName = 'MyAwesomeComponent'