MrBlenny / react-flow-chart

🌊 A flexible, stateless, declarative flow chart library for react.
https://mrblenny.github.io/react-flow-chart/index.html
MIT License
1.46k stars 307 forks source link

onCanvasDrop: Support id from data argument #96

Closed NoyTse closed 4 years ago

NoyTse commented 4 years ago

When using external state and drag&drop, it may be useful to store the new item in DB / Redux when the onCanvasDrop event is fired, but still wrap the chart with component with inner-state, and use the default "action handlers" from the libary to maintain the state.

So, with this patch we can choose the id in

onDragStart={(ev) => { 
    ev.dataTransfer.setData(
        REACT_FLOW_CHART, 
        JSON.stringify({ id: chosenId, ...newNode) }
    ) 
}}

hope you found this helpfully, Noy