Improve TSDoc comments for useNodesData, useReactFlow, isNode and isEdge

This commit is contained in:
Dimitri POSTOLOV
2025-04-06 04:52:08 +02:00
parent b9e4f82933
commit e6139a00d4
4 changed files with 22 additions and 13 deletions
+6 -4
View File
@@ -8,11 +8,9 @@ import type { Node } from '../types';
* This hook lets you subscribe to changes of a specific nodes `data` object.
*
* @public
* @param nodeId - The id (or ids) of the node to get the data from
* @returns An object (or array of object) with {id, type, data} representing each node
* @returns An object (or array of object) with `id`, `type`, `data` representing each node.
*
* @example
*
*```jsx
*import { useNodesData } from '@xyflow/react';
*
@@ -25,9 +23,13 @@ import type { Node } from '../types';
*```
*/
export function useNodesData<NodeType extends Node = Node>(
/** The id of the node to get the data from. */
nodeId: string
): Pick<NodeType, 'id' | 'type' | 'data'> | null;
export function useNodesData<NodeType extends Node = Node>(nodeIds: string[]): Pick<NodeType, 'id' | 'type' | 'data'>[];
export function useNodesData<NodeType extends Node = Node>(
/** The ids of the nodes to get the data from. */
nodeIds: string[]
): Pick<NodeType, 'id' | 'type' | 'data'>[];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function useNodesData(nodeIds: any): any {
const nodesData = useStore(