Skip to main content
useDailyEvent(params): void Listeners are automatically torn down when the calling component or hook unmounts.

Parameters

event
string
required
The daily-js event to register.
callback
Function
required
A memoized callback reference to run when the event is emitted.
The callback param has to be a memoized reference (e.g. via useCallback). Otherwise a console error might be thrown indicating a potential re-render loop.

Example

import { useDailyEvent } from '@daily-co/daily-react';
import { useCallback, useState } from 'react';

export const DailyEventDemo = () => {
  const [meetingState, setMeetingState] = useState('disconnected');

  useDailyEvent(
    'joined-meeting',
    useCallback((ev) => {
      setMeetingState('connected');
    }, [])
  );

  return <div>Meeting state: {meetingState}</div>;
};

See also