Function CoHostModal

CoHostModal component allows managing co-host settings for an event.

This component displays a modal that enables users to select a new co-host from the list of participants, assign responsibilities, and save the updated settings. Real-time communication is facilitated using a Socket instance, and it includes customizable options for modal appearance and position.

import React from 'react';
import { CoHostModal } from 'mediasfu-reactjs';
import { io } from 'socket.io-client';

function App() {
const isCoHostModalVisible = true;
const onCoHostClose = () => console.log('Co-host modal closed');
const onModifyEventSettings = (settings) => console.log('Settings modified', settings);
const currentCohost = 'John Doe';
const participants = [
{ name: 'John Doe', islevel: '1' },
{ name: 'Jane Doe', islevel: '0' }
];
const coHostResponsibility = [
{ name: 'manageParticipants', value: true, dedicated: false }
];
const position = 'topRight';
const backgroundColor = '#83c0e9';
const roomName = 'Room 1';
const showAlert = ({ message, type }) => console.log('Alert:', message, type);
const updateCoHostResponsibility = (responsibilities) => console.log('Co-host responsibilities updated', responsibilities);
const updateCoHost = (coHost) => console.log('Co-host updated', coHost);
const updateIsCoHostModalVisible = (visible) => console.log('Co-host modal visibility:', visible);
const socket = io('http://localhost:3000');

return (
<CoHostModal
isCoHostModalVisible={isCoHostModalVisible}
onCoHostClose={onCoHostClose}
onModifyEventSettings={onModifyEventSettings}
currentCohost={currentCohost}
participants={participants}
coHostResponsibility={coHostResponsibility}
position={position}
backgroundColor={backgroundColor}
roomName={roomName}
showAlert={showAlert}
updateCoHostResponsibility={updateCoHostResponsibility}
updateCoHost={updateCoHost}
updateIsCoHostModalVisible={updateIsCoHostModalVisible}
socket={socket}
/>
);
}

export default App;

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'