-
-
Notifications
You must be signed in to change notification settings - Fork 109
Description
Here are two points that I think could be improved, based on my own experience adopting the library:
-
The
useStoreexported from@xyflow/reactcan be easily confused with theuseStoreexported fromzustand. Since React Flow useszustandinternally 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 whichuseStoreis 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
setEdgesandsetNodesreturned byuseReactFlow()are very easy to confuse with the React state setters you get fromuseState()(and thesetNodesreturned byuseNodesState()). In the reference examples foruseNodesState(),applyEdgeChanges(), andapplyNodeChanges(), thesetEdges/setNodesused 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/setNodesfromuseReactFlow()do not behave like React state setters—they transform the input intoedgeChanges/nodeChangesand then apply those changes.
If renaming is not realistic, perhaps some clarifications in the docs could help.
Just my two cents :)