Skip to content

🎥 Make videos programmatically with React

Update Programmatic.tsx

Jonny Burger60fd472f8199
diff --git a/packages/docs/components/LandingPage/Programmatic.tsx b/packages/docs/components/LandingPage/Programmatic.tsx
index a755ae454a..e4f33b97d0 100644
--- a/packages/docs/components/LandingPage/Programmatic.tsx
+++ b/packages/docs/components/LandingPage/Programmatic.tsx
@@ -11,15 +11,17 @@ export const ProgrammaticContent: React.FC<{ data: GithubResponse | null }> = ({
const [isIntersecting, setIsIntersecting] = useState(false);
- const callback: IntersectionObserverCallback = useCallback((data) => {
- const { isIntersecting } = data[0];
- setIsIntersecting(isIntersecting);
- if (isIntersecting) {
- playerRef.current?.play();
- } else {
- playerRef.current?.pause();
- }
- }, []);
+ const callback: IntersectionObserverCallback = useCallback(
+ (newData) => {
+ setIsIntersecting(newData[0].isIntersecting);
+ if (isIntersecting) {
+ playerRef.current?.play();
+ } else {
+ playerRef.current?.pause();
+ }
+ },
+ [isIntersecting]
+ );
useEffect(() => {
const { current } = containerRef;