[Proposal]: Need support to accept JSON object instead Array for elements
See original GitHub issueCurrently 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.
- Curretly i need to get the index of the clicked node first
- Clone the entire elements and update the node based on the index we got from the first point
- 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:
- Created 3 years ago
- Reactions:5
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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’sO(1)(constant time).Hey @pradeepravi-cse
It’s a good point. We are thinking about using a Map as the new data structure for nodes #681.