Skip to content

🎥 Make videos programmatically with React

fix render

Jonny Burger4c450751009d
diff --git a/packages/bundler/src/renderEntry.tsx b/packages/bundler/src/renderEntry.tsx
index c89436f34c..9d5bf02391 100644
--- a/packages/bundler/src/renderEntry.tsx
+++ b/packages/bundler/src/renderEntry.tsx
@@ -85,12 +85,20 @@ const GetVideo: React.FC<{state: BundleState}> = ({state}) => {
}, [Component, state.type]);
useEffect(() => {
+ if (!video) {
+ return;
+ }
+
const {current} = portalContainer;
- current?.appendChild(Internals.portalNode());
+ if (!current) {
+ throw new Error('portal did not render');
+ }
+
+ current.appendChild(Internals.portalNode());
return () => {
- current?.removeChild(Internals.portalNode());
+ current.removeChild(Internals.portalNode());
};
- }, []);
+ }, [video]);
if (!video) {
return null;