Merge pull request #5166 from dimaMachina/tsdoc2-12

Improve TSDoc comments for `useStore` hook
This commit is contained in:
Moritz Klack
2025-04-06 21:02:59 +02:00
committed by GitHub
2 changed files with 13 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@xyflow/react': patch
---
Improve TSDoc comments for `useStore` hook
+8 -5
View File
@@ -14,9 +14,13 @@ const zustandErrorMessage = errorMessages['error001']();
* state management library, so you should check out their docs for more details. * state management library, so you should check out their docs for more details.
* *
* @public * @public
* @param selector * @param selector - A selector function that returns a slice of the flow's internal state.
* @param equalityFn * Extracting or transforming just the state you need is a good practice to avoid unnecessary
* @returns The selected state slice * re-renders.
* @param equalityFn - A function to compare the previous and next value. This is incredibly useful
* for preventing unnecessary re-renders. Good sensible defaults are using `Object.is` or importing
* `zustand/shallow`, but you can be as granular as you like.
* @returns The selected state slice.
* *
* @example * @example
* ```ts * ```ts
@@ -43,8 +47,7 @@ function useStore<StateSlice = unknown>(
/** /**
* In some cases, you might need to access the store directly. This hook returns the store object which can be used on demand to access the state or dispatch actions. * In some cases, you might need to access the store directly. This hook returns the store object which can be used on demand to access the state or dispatch actions.
* *
* @returns The store object * @returns The store object.
*
* @example * @example
* ```ts * ```ts
* const store = useStoreApi(); * const store = useStoreApi();