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.

[Proposal]: Need support to accept JSON object instead Array for elements

See original GitHub issue

Currently we are using array of elements as input to the react-flow-render. Its very difficult to update one element properties

e.g

I want to update one node object based on the click or whatever.

  1. Curretly i need to get the index of the clicked node first
  2. Clone the entire elements and update the node based on the index we got from the first point
  3. update the entire elements

Proposal:

If we change the elements to Object. like the below. it will be easy to update the tree

{
  "etQRriCEb44snkFQIQ6_r": {
    "id": "etQRriCEb44snkFQIQ6_r",
    "type": "customNode",
    "data": {
      "label": "custom Node",
      "color": "#800080"
    },
    "position": {
      "x": 597,
      "y": 162
    }
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
MonliHcommented, Mar 7, 2021

I also would like to see an object here, as it seems to make more sense. I think this would improve performance a lot, especially when there are very many nodes: looking for an element with a given id on an array is O(n) (the more nodes, the slower it gets), while on an object it’s O(1) (constant time).

6reactions
moklickcommented, Dec 3, 2020

Hey @pradeepravi-cse

It’s a good point. We are thinking about using a Map as the new data structure for nodes #681.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Will JSON Evolve to Have Native Support for Ecmascript Map ...
No, because JSON notation, while it originated with Javascript, is widely used in a very large number of languages, but a Javascript Map ......
Read more >
A beginner's guide to JSON, the data format for the internet
When APIs send data, chances are they send it as JSON objects. Here's a primer on why JSON is how networked applications send...
Read more >
Handling non-compliant JSON with Jackson - cowtowncoder
With its default settings Jackson always produces (generates) valid JSON; and similarly only accepts syntactically valid JSON content to ...
Read more >
Work with JSON data - SQL Server - Microsoft Learn
JSON data in SQL Server. ... Overview of built-in JSON support ... JSON documents may have sub-elements and hierarchical data that cannot be ......
Read more >
JSONPath -- XPath for JSON - IETF Datatracker
attribute access. JSON data items don't have attributes. [], [], subscript operator. XPath uses it to iterate over element collections ...
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