From d536abea9240bad7f5c1064efc0a4713ebef87d1 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Sat, 5 Apr 2025 17:37:43 +0200 Subject: [PATCH] Improve TSDoc comments for `useViewport`, `useUpdateNodeInternals`, `useOnSelectionChange`, `useNodesInitialized` hooks and `UseOnSelectionChangeOptions`, `UseNodesInitializedOptions` types --- .changeset/beige-apes-repair.md | 5 +++++ packages/react/src/hooks/useNodesInitialized.ts | 5 +++-- packages/react/src/hooks/useOnSelectionChange.ts | 3 +-- packages/react/src/hooks/useUpdateNodeInternals.ts | 9 +++++---- packages/react/src/hooks/useViewport.ts | 6 +++--- 5 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 .changeset/beige-apes-repair.md diff --git a/.changeset/beige-apes-repair.md b/.changeset/beige-apes-repair.md new file mode 100644 index 00000000..252866a3 --- /dev/null +++ b/.changeset/beige-apes-repair.md @@ -0,0 +1,5 @@ +--- +'@xyflow/react': patch +--- + +Improve TSDoc comments for `useViewport`, `useUpdateNodeInternals`, `useOnSelectionChange`, `useNodesInitialized` hooks and `UseOnSelectionChangeOptions`, `UseNodesInitializedOptions` types diff --git a/packages/react/src/hooks/useNodesInitialized.ts b/packages/react/src/hooks/useNodesInitialized.ts index 38f15a60..a44ab658 100644 --- a/packages/react/src/hooks/useNodesInitialized.ts +++ b/packages/react/src/hooks/useNodesInitialized.ts @@ -4,6 +4,7 @@ import { useStore } from './useStore'; import type { ReactFlowState } from '../types'; export type UseNodesInitializedOptions = { + /** @default false */ includeHiddenNodes?: boolean; }; @@ -29,8 +30,8 @@ const selector = (options: UseNodesInitializedOptions) => (s: ReactFlowState) => *`false` and then `true` again once the node has been measured. * * @public - * @param options.includeHiddenNodes - defaults to false - * @returns boolean indicating whether all nodes are initialized + * @returns Whether or not the nodes have been initialized by the `` component and + * given a width and height. * * @example * ```jsx diff --git a/packages/react/src/hooks/useOnSelectionChange.ts b/packages/react/src/hooks/useOnSelectionChange.ts index 17232895..feff9fe3 100644 --- a/packages/react/src/hooks/useOnSelectionChange.ts +++ b/packages/react/src/hooks/useOnSelectionChange.ts @@ -4,6 +4,7 @@ import { useStoreApi } from './useStore'; import type { OnSelectionChangeFunc, Node, Edge } from '../types'; export type UseOnSelectionChangeOptions = { + /** The handler to register. */ onChange: OnSelectionChangeFunc; }; @@ -13,8 +14,6 @@ export type UseOnSelectionChangeOptions ({ /** * The `useViewport` hook is a convenient way to read the current state of the - *{@link Viewport} in a component. Components that use this hook - *will re-render **whenever the viewport changes**. + * {@link Viewport} in a component. Components that use this hook + * will re-render **whenever the viewport changes**. * * @public - * @returns The current viewport + * @returns The current viewport. * * @example *