You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to use ReactFlowInstance, and based on that I saw that you can also set nodes in view, which is a very practical way of doing so because you can use the reference as a global state instance and call it even on functions outside the components.
But I could've figured out how to do it, the method has attached the functions of setting the nodes and similar, when I call it to add the nodes it doesn't work, and when I print after the nodes it still an empty array, is this a correct way or missing something? Because what's the point of managing the node with state and reference setting the nodes?
So I have tried using the onInit method that provides a reference, also using the hook itself both of them don't set the nodes.
I'm calling it from inside the provider, but I won't separate here the components for the sake of simplicity. Our example with onInit, but using the hook gives the same results so I will skip:
Here is my function where I try to set some test nodes:
constfuncThatReturnsTheReference=(ref: ReactFlowInstance)=>{console.log(ref.getNodes())// list 0 nodesref.setNodes([...normalNodes])console.log(ref.getNodes())// list 0 nodes again}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I wanted to use ReactFlowInstance, and based on that I saw that you can also set nodes in view, which is a very practical way of doing so because you can use the reference as a global state instance and call it even on functions outside the components.
But I could've figured out how to do it, the method has attached the functions of setting the nodes and similar, when I call it to add the nodes it doesn't work, and when I print after the nodes it still an empty array, is this a correct way or missing something? Because what's the point of managing the node with state and reference setting the nodes?
So I have tried using the onInit method that provides a reference, also using the hook itself both of them don't set the nodes.
I'm calling it from inside the provider, but I won't separate here the components for the sake of simplicity. Our example with onInit, but using the hook gives the same results so I will skip:
Here is my function where I try to set some test nodes:
I'm missing something?
Beta Was this translation helpful? Give feedback.
All reactions