question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PlotlyEditor handleUpdate mutates inputs instead of following unidirectional data flow

See original GitHub issue

Due to the way the editor is wired to depend on the graphDiv DOM element from react-plotly.js, handleUpdate is mutating the data/layout, and then uses onUpdate as a “something changed” flag. So, it’s essentially just bypassing the React render loop altogether by flowing some data mutations directly back to the embedded Plotly inside react-plotly.js.

What it should be doing is using something like immutability-helper to create an updated immutable copy of data/layout, and then send back those changes out as values to the onUpdate callback. The callback would then update the higher state, and those new changes would flow back down into the data & layout props of both the Plot and PlotlyEditor components.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
nicolaskruchtencommented, Feb 26, 2018

I’m definitely not dismissing immutability, I’m working hard to promote it and we’re making changes to plotly.js to use it! 😃

That said, copying large arrays is much slower than “not exactly the same” … Per https://jsperf.com/copy-large-array/1 for me the slice-and-push operation runs at ~60 ops/sec and the push-only runs at ~30,000,000 ops/sec.

0reactions
nicolaskruchtencommented, Mar 7, 2018

Once #384 settles down, it will be easier to resolve this (and #212, which was already intended to do this!) as per https://github.com/plotly/react-chart-editor/pull/384#discussion_r172730087

Read more comments on GitHub >

github_iconTop Results From Across the Web

Master React Unidirectional Data Flow
Understanding React unidirectional data flow is integral to scaffolding scalable applications.
Read more >
Unidirectional data flow in React
I've made the following snippets to sense the essential difference, then it seems that the unidirectional mandates the application to propagate ...
Read more >
Why does React emphasize on unidirectional data flow ...
Unidirectional data flow is a technique found in functional reactive programming. ... Also an input field in the view can mutate your model....
Read more >
Unidirectional Data flow in React
What is Unidirectional Data Flow? React is a library that allows developers to build reusable components and insist on one-way data flow.
Read more >
Unidirectional Data Flow - Two Ways
I needed to modify the model slightly so I could take inputs using US Customary Units rather than SI Units. The end result...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found