React-diagrams: How to pass data from widget to node?

Created on 15 Jul 2019  路  8Comments  路  Source: projectstorm/react-diagrams

I have trouble with passing data from widget to node. I have textfield in my widget and I need to pass the text that is inputed to the node so that that text appears there while user prints text. I used demo and just added this features. Is it possible to pass data from there to the node?

Most helpful comment

I did it by implementing my own NodeFactory. I think DiamondNode demo (Demo 3) should demonstrate this. Anyways I can post an example later today

All 8 comments

I did it by implementing my own NodeFactory. I think DiamondNode demo (Demo 3) should demonstrate this. Anyways I can post an example later today

@JokerNN would you mind posting an example using JSX? I can't make custom nodes work #281

Hey @sedulka, I think I misunderstood your question first time, so I didn't really do it before :) However I think I know what can be done, so Im fiddling in codesandbox and let's see how it goes

@JokerNN Nodes have a data property which is an object. You can store your data in there by modifying node.data directly in your widget. It breaks the one way data flow pattern of React, but it's the most simple and effective way to get the job done.

The demo that you send is not solving my issue. I am talking about widget with blocks, from where you can pull them to the diagram. I rewrote it in the other component and need to pass data from that widget to block.

@sedulka
DiagramModel has method getNode(nodeId) you can get node, update properties and then repaint canvas via DiagramEngine method repaintCanvas

@sedulka
I don't know if it can help you, but if you're trying to pass data from a textInput to the model, look at my repository: https://github.com/mathiasbaldissera/react-diagrams-editable-node
There's a node that can be edited, and a serialization button to verify if the data was changed successfully on the model (just use CTRL+F to look the node "content")

Was this page helpful?
0 / 5 - 0 ratings

Related issues

M2Costa picture M2Costa  路  3Comments

dixitk13 picture dixitk13  路  3Comments

Naveenraj006 picture Naveenraj006  路  3Comments

iddan picture iddan  路  3Comments

affanshahid picture affanshahid  路  3Comments