I’m using React Flow, I’m new to it, so I saw they have a hook that say they can manage nodes with it but that is not clear, so on Init
I set the Reference
and then set that to a global state (even I don’t set still the same result).
So when I call Reactflow.getNodes()
, it prints the nodes but when I call Reactflow.addNodes([...nodes])
it doesn’t say anything nor add not a node.
If that would be possible then this would be very simplified because we could import the Reference
to other functions and manage the nodes in very structured way but I don’t seem to find a way to do it yet.
Let me break the structure:
So as I understand, ReactflowProvider
allows you to access the states outside the flow, and references it
<ReactFlowProvider>
<ReactFlow ref={reactFlow} />
</ReactFlowProvider>
Then this function should set the nodes on itself, without using any other hook right, because I don’t understand a reference as like this? The documentation is not clear on this
reactflow.setNodes([...])
I did try to ref it, and on Init
still the same