Function PollModal

PollModal component renders a modal for creating, viewing, and managing polls.

import { PollModal } from 'mediasfu-reactjs';
import { io } from 'socket.io-client';

// Define poll array and poll objects
const polls = [
{
id: "1",
question: "Do you like React?",
options: ["Yes", "No"],
votes: [0, 0],
status: "active",
},
];
const currentPoll = polls[0];
const socket = io("http://localhost:3000");

// Render the PollModal component
<PollModal
isPollModalVisible={true}
onClose={() => console.log("Modal closed")}
position="topRight"
backgroundColor="#f5f5f5"
member="user1"
islevel="2"
polls={polls}
poll={currentPoll}
socket={socket}
roomName="Room 1"
showAlert={(message, type) => console.log("Show alert:", message, type)}
updateIsPollModalVisible={() => console.log("Toggle poll modal visibility")}
handleCreatePoll={(pollOptions) => console.log("Create poll:", pollOptions)}
handleEndPoll={(pollId) => console.log("End poll:", pollId)}
handleVotePoll={(voteOptions) => console.log("Vote in poll:", voteOptions)}
/>

Properties

propTypes?: WeakValidationMap<PollModalOptions>

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<PollModalOptions>

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'