mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
* 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
33 lines
665 B
TypeScript
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>
|
|
);
|
|
};
|