Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 515 Bytes

react.md

File metadata and controls

22 lines (17 loc) · 515 Bytes
import React, { useRef, useEffect } from 'react';
import ReactDOM from 'react-dom';
import { loadPlayer } from 'rtsp-relay/browser';

const App: React.VFC = () => {
  const canvas = useRef<HTMLCanvasElement>(null);

  useEffect(() => {
    if (!canvas.current) throw new Error('Ref is null');

    loadPlayer({
      url: 'ws://localhost:2000/api/stream/2',
      canvas: canvas.current,
    });
  }, []);

  return <canvas ref={canvas} />;
};

ReactDOM.render(<App />, document.getElementById('root'));