close
close

Basics of Commenting ~ useRef/play video – DEV Community

・src/Example.js

import { useRef, useState } from "react";

const Video = () => {
  const (playing, setPlaying) = useState();
  const videoRef = useRef();

  return (
    

); }; const Example = () => { return (
Go to full screen mode

Exit full screen mode

・We set the useRef value as videoRef for the video element’s ref attribute.

・When we press the button, we can control the video action with videoRef.current.pause() or videoRef.current.play() in the button’s onClick function.

・This is a play action.

Image description

・This is a stop action.

Image description

Sorry, I can’t show the action as a video.