excalidraw/packages/excalidraw/components/SVGLayer.tsx
Aakansha Doshi 1ed53b153c
build: enable consistent type imports eslint rule (#7992)
* build: enable consistent type imports eslint rule

* change to warn

* fix the warning in example and excalidraw-app

* fix packages

* enable type annotations and throw error for the rule
2024-05-08 14:21:50 +05:30

33 lines
665 B
TypeScript

import { useEffect, useRef } from "react";
import type { Trail } from "../animated-trail";
import "./SVGLayer.scss";
type SVGLayerProps = {
trails: Trail[];
};
export const SVGLayer = ({ trails }: SVGLayerProps) => {
const svgRef = useRef<SVGSVGElement | null>(null);
useEffect(() => {
if (svgRef.current) {
for (const trail of trails) {
trail.start(svgRef.current);
}
}
return () => {
for (const trail of trails) {
trail.stop();
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, trails);
return (
<div className="SVGLayer">
<svg ref={svgRef} />
</div>
);
};