Skip to main content
useCallObject(): DailyCall When manually managing call object instances in React, it’s easy to run into issues like Error: Duplicate DailyIframe instances are not allowed, especially in React’s Strict Mode. useCallObject() handles that for you.
useCallObject creates and destroys a call object instance. useDaily provides access to the call object instance passed to or managed by DailyProvider.

Parameters (optional)

useCallObject accepts the same configuration options as createCallObject().
options
DailyFactoryOptions
Contains all factory properties that are passed to createCallObject(). Check DailyCall properties for details.
shouldCreateInstance
Function
Optional callback function with a boolean return to control when the call object instance should be created.

Return value

DailyCall
DailyCall
The DailyCall instance.

Example

import { useCallback, useRef } from 'react';
import { DailyProvider, useCallObject } from '@daily-co/daily-react';

export const UseCallObjectDemo = () => {
  const callRef = useRef(null);
  const callObject = useCallObject();
  return (
    <DailyProvider callObject={callObject}>
      <div ref={callRef} />
    </DailyProvider>
  );
};

See also

Components

daily-js methods