Skip to content

🎥 Make videos programmatically with React

one more instance

Jonny Burger3e619ee1c4c6
diff --git a/packages/core/src/buffering.tsx b/packages/core/src/buffering.tsx
index bc0bf13c02..8ec0132fcb 100644
--- a/packages/core/src/buffering.tsx
+++ b/packages/core/src/buffering.tsx
@@ -111,21 +111,24 @@ const useBufferManager = (
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [blocks]);
- useLayoutEffect(() => {
- if (blocks.length === 0) {
- onResumeCallbacks.forEach((c) => c());
- playbackLogging({
- logLevel,
- message: 'Player is exiting buffer state',
- mountTime,
- tag: 'player',
- });
- }
- // Intentionally only firing when blocks change, not the callbacks
- // otherwise a resume callback might remove itself after being called
- // and trigger again
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [blocks]);
+ if (typeof window !== 'undefined') {
+ // eslint-disable-next-line react-hooks/rules-of-hooks
+ useLayoutEffect(() => {
+ if (blocks.length === 0) {
+ onResumeCallbacks.forEach((c) => c());
+ playbackLogging({
+ logLevel,
+ message: 'Player is exiting buffer state',
+ mountTime,
+ tag: 'player',
+ });
+ }
+ // Intentionally only firing when blocks change, not the callbacks
+ // otherwise a resume callback might remove itself after being called
+ // and trigger again
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [blocks]);
+ }
return useMemo(() => {
return {addBlock, listenForBuffering, listenForResume, buffering};