title: jump to specific time in videojs using react hooks
body: <p>I am trying to implement feature to jump 15 seconds forward or backward in video.</p>
  <p>I am facing hard time to set the update and set the current time.</p>
  <pre><code>const videoNode = useRef(null);
    const [currentTime, setCurrentTime] = useState(null);
  
    const handleTimeJump = (type) =&gt; {
      const player = videojs(videoNode.current);
      console.log(player)
      if (player) {
        type === 'inc' &amp;&amp; setCurrentTime(player.currentTime() + 15);
        player.currentTime() &gt; 15 ? setCurrentTime(player.currentTime() - 15) : setCurrentTime(0)
      }
    };
  
    useEffect(() =&gt; {
      const player = videojs(
        videoNode.current,
        videoJsOptions,
        function onPlayerReady() {
          console.log('onPlayerReady');
          player.on('timeupdate', () =&gt; {
            setCurrentTime(player.currentTime());
          });
        },
      );
      if (!videoJsOptions.sources[0].src) {
        console.log('no source found');
      }
      return () =&gt; {
        if (player) {
          player.dispose();
        }
      };
    }, []);
  
    useEffect(() =&gt; {
      const player = videojs(videoNode.current)
      player.currentTime(currentTime)
  }, [currentTime])
  </code></pre>
  <p>handleTimeJump is called after clicking a button.</p>
  <pre><code>onClick={() =&gt; handleTimeJump('inc')}
  </code></pre>