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

Performance when using external state #86

Closed lordi closed 4 years ago

lordi commented 4 years ago

I implement a simple handler that does not mutate the original state, unlike the bundled handler.

With this handler I experience bad performance. Do you see any way to have the same performance as FlowChartWithState but with immutable, external state or is this limitation foundamental in nature?

For reference, here is my handler using ramda:

const [ chart, setChart ] = React.useState<IChart>(initialChart);
const nodePositionL = (nodeId: string) => R.lensPath(['nodes', nodeId, 'position']) 
const onDragNode = ({ id, data }) => { setChart(R.set(nodePositionL(id), {x: data.x, y: data.y}, chart)) },      
...                             

Edit: And BTW congrats on the great library, I'm watching the progress for a year now :+1:

lordi commented 4 years ago

My bad, performance seems ok when developer tools are closed.