Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sample code for wiring up event listeners in a Daily-powered React video chat app
// In Call.js
useEffect(() => {
if (!callObject) return;
const events = [
function handleNewParticipantsState(event) {
event && logDailyEvent(event);
participants: callObject.participants()
// Use initial state
// Listen for changes in state
for (const event of events) {
callObject.on(event, handleNewParticipantsState);
// Stop listening for changes in state
return function cleanup() {
for (const event of events) {
callObject &&, handleNewParticipantsState);
}, [callObject]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.