import React, { useRef, useState, useEffect } from "react"; import { RendererContext } from "./RendererContext"; import { PanZoom } from "./PanZoom"; export const PanZoomWrapper = ({ children }: { children: React.ReactNode }) => { const wrapper = useRef(null); const zoom = useRef(null); const move = useRef(null); const instance = useRef(new PanZoom()).current; useEffect(() => { const $wrapper = wrapper.current; const $zoom = zoom.current; const $move = move.current; if ($wrapper && $zoom && $move) { instance.initialize($wrapper, $zoom, $move); } return () => { instance.cleanup(); }; }, []); return (
{children}
); };