You can re-use the
daily-js call frame or call object multiple times (a sequence of
join(), etc method calls will work as expected).
But when you are finished with the
daily-js call object, you should call
destroy() to free all resources associated with it.
This is particularly important if you plan to create another
daily-js object in the future. If you don't call
destroy(), and later create a new
daily-js call object, the event listeners from the old object and the new object will interfere with one another.
daily-js 0.43.0, using a call instance after calling
destroy() on it will not be allowed and any attempt will throw an
Error in order to help defend against this. If you believe you may be using destroyed instances and wish to preview this behavior, add
strictMode: true to the
properties passed in to your factory method.
If you're using Daily Prebuilt,
destroy() is also useful to call after a participant leaves. The method removes all resources, including any remaining frame that the call might leave behind on the page (if you're not styling the parent container).
destroy() in action
- Tutorial: Building a custom video chat app with React
- Demo repository: