-
-
Notifications
You must be signed in to change notification settings - Fork 107
Description
Here are two points that I think could be improved, based on my own experience adopting the library:
-
The
useStore
exported from@xyflow/react
can be easily confused with theuseStore
exported fromzustand
. Since React Flow useszustand
internally and also provides zustand introductions on the website, this confusion can become even stronger. In some documentation pages where the context is missing, it’s not always clear whichuseStore
is being referenced. However, these two hooks are not the same thing and have different function signatures. In our project, to keep things clear for myself and my colleagues, I usually write:import { useStore as useReactFlowStore } from "@xyflow/react";
-
The names
setEdges
andsetNodes
returned byuseReactFlow()
are very easy to confuse with the React state setters you get fromuseState()
(and thesetNodes
returned byuseNodesState()
). In the reference examples foruseNodesState()
,applyEdgeChanges()
, andapplyNodeChanges()
, thesetEdges
/setNodes
used there are indeed the React state setters (or the setter fromuseNodesState()
), not the methods fromuseReactFlow()
. Because both use the same names, it can be hard for users who are skimming or jumping between pages (especially those trying to figure out how to use the component in a controlled mode) to realize that thesetEdges
/setNodes
fromuseReactFlow()
do not behave like React state setters—they transform the input intoedgeChanges
/nodeChanges
and then apply those changes.
If renaming is not realistic, perhaps some clarifications in the docs could help.
Just my two cents :)