Skip to content

Commit 23e9262

Browse files
committed
improve call frame parentEl ref handling
1 parent 72febae commit 23e9262

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/hooks/useCallInstance.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@ export const useCallInstance = (
3737
*/
3838
const lastUsedOptions = useRef<DailyFactoryOptions>();
3939
useEffect(() => {
40-
if (!shouldCreateInstance()) {
40+
/**
41+
* Call frame instances with a defined parentEl likely pass a ref.
42+
* Typically a DOM ref is initialized with useRef(null).
43+
* We'll want to wait until parentEl is defined, meaning that the ref is
44+
* correctly wired up with a DOM element.
45+
* Otherwise we'll just check shouldCreateInstance().
46+
*/
47+
if ((type === 'callFrame' && parentEl === null) || !shouldCreateInstance())
4148
return;
42-
}
4349

4450
async function destroyCallInstance(co: DailyCall) {
4551
await co.destroy();

0 commit comments

Comments
 (0)