MCPcopy
hub / github.com/clientIO/joint / useElements

Function useElements

packages/joint-react/src/hooks/use-elements.ts:59–78  ·  view source on GitHub ↗
(
  selector: (
    items: CellMap<Elements>
  ) => SelectorReturnType = defaultSelector as () => SelectorReturnType,
  isEqual: (a: SelectorReturnType, b: SelectorReturnType) => boolean = util.isEqual
)

Source from the content-addressed store, hash-verified

57 * @returns - The selected elements.
58 */
59export function useElements<
60 Elements extends GraphElement = GraphElement,
61 SelectorReturnType = Elements[],
62>(
63 selector: (
64 items: CellMap<Elements>
65 ) => SelectorReturnType = defaultSelector as () => SelectorReturnType,
66 isEqual: (a: SelectorReturnType, b: SelectorReturnType) => boolean = util.isEqual
67): SelectorReturnType {
68 const { subscribe, getElements } = useGraphStore();
69 const typedGetElements = getElements as () => CellMap<Elements>;
70 const elements = useSyncExternalStoreWithSelector(
71 subscribe,
72 typedGetElements,
73 typedGetElements,
74 selector,
75 isEqual
76 );
77 return elements;
78}

Callers 15

GraphProviderHandlerFunction · 0.90
TestComponentFunction · 0.90
ComponentFunction · 0.90
MainFunction · 0.90
MainFunction · 0.90
MainFunction · 0.90
MainFunction · 0.90
MainFunction · 0.90

Calls 1

useGraphStoreFunction · 0.90

Tested by 1

TestComponentFunction · 0.72