diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-27 00:55:15 +0100 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-29 15:56:48 +0200 |
| commit | 4d127a038bf768eded68aae3cfa5c1b12241bdac (patch) | |
| tree | 16bbb801caf6770546cff4fdb37b6408ec9ead98 /legacy/use-element-registry.ts | |
| parent | 82817cb50cb0487350573d6129130aec705f924b (diff) | |
| download | opencut-4d127a038bf768eded68aae3cfa5c1b12241bdac.tar.gz | |
chore: normalize line endings
Diffstat (limited to 'legacy/use-element-registry.ts')
| -rw-r--r-- | legacy/use-element-registry.ts | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/legacy/use-element-registry.ts b/legacy/use-element-registry.ts index 85704318..df3315cb 100644 --- a/legacy/use-element-registry.ts +++ b/legacy/use-element-registry.ts @@ -1,31 +1,31 @@ -import { useCallback, useRef } from "react"; - -export function useElementRegistry() { - const elementRefs = useRef<Map<string, HTMLElement>>(new Map()); - - const registerElement = useCallback( - (id: string, element: HTMLElement | null) => { - if (element) { - elementRefs.current.set(id, element); - return; - } - - elementRefs.current.delete(id); - }, - [], - ); - - const getElement = useCallback((id: string) => { - return elementRefs.current.get(id) ?? null; - }, []); - - const getElements = useCallback(() => { - return elementRefs.current; - }, []); - - return { - registerElement, - getElement, - getElements, - }; -} +import { useCallback, useRef } from "react";
+
+export function useElementRegistry() {
+ const elementRefs = useRef<Map<string, HTMLElement>>(new Map());
+
+ const registerElement = useCallback(
+ (id: string, element: HTMLElement | null) => {
+ if (element) {
+ elementRefs.current.set(id, element);
+ return;
+ }
+
+ elementRefs.current.delete(id);
+ },
+ [],
+ );
+
+ const getElement = useCallback((id: string) => {
+ return elementRefs.current.get(id) ?? null;
+ }, []);
+
+ const getElements = useCallback(() => {
+ return elementRefs.current;
+ }, []);
+
+ return {
+ registerElement,
+ getElement,
+ getElements,
+ };
+}
|
