PollModal - Interactive polling and voting interface

PollModal is a React Native component that provides a complete polling system for meetings. Hosts/co-hosts can create polls with multiple options, participants can vote, and results are displayed in real-time with vote counts and percentages.

Key Features:

  • Poll creation with custom question and multiple options (host/co-host only)
  • Real-time voting for participants
  • Live vote count and percentage display
  • Poll history view (all active and inactive polls)
  • End poll functionality (host/co-host only)
  • Single vote per participant enforcement
  • Socket.io synchronization for instant updates
  • Position-configurable modal (5 positions)

UI Customization: This component can be replaced via uiOverrides.pollModal to provide a completely custom polling interface.

// Host creating and managing polls
import React, { useState } from 'react';
import { PollModal } from 'mediasfu-reactnative-expo';
import { io } from 'socket.io-client';

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

const activePoll = {
id: 'poll-1',
question: 'What time works best?',
options: ['Morning', 'Afternoon', 'Evening'],
status: 'active',
voters: { 'user1': 0, 'user2': 2 },
votes: [1, 0, 1],
};

return (
<PollModal
isPollModalVisible={showPolls}
onClose={() => setShowPolls(false)}
member="host-user"
islevel="2" // Host - can create/end polls
polls={[activePoll]}
poll={activePoll}
socket={socket}
roomName="meeting-room-123"
handleCreatePoll={handleCreatePoll}
handleEndPoll={handleEndPoll}
handleVotePoll={handleVotePoll}
updateIsPollModalVisible={setShowPolls}
showAlert={showCustomAlert}
/>
);
// Participant voting in polls
return (
<PollModal
isPollModalVisible={isVisible}
onClose={handleClose}
member="participant-user"
islevel="0" // Participant - can only vote
polls={allPolls}
poll={currentPoll}
socket={socketConnection}
roomName={roomId}
handleCreatePoll={handleCreatePoll}
handleEndPoll={handleEndPoll}
handleVotePoll={handleVotePoll}
updateIsPollModalVisible={setIsVisible}
position="center"
backgroundColor="#e8f5e9"
/>
);
// Using custom UI via uiOverrides
const config = {
uiOverrides: {
pollModal: {
component: MyCustomPollInterface,
injectedProps: {
theme: 'dark',
allowAnonymousVoting: false,
},
},
},
};

return <MyMeetingComponent config={config} />;

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'