useNode, useEdge hooks
See original GitHub issueI think it would be great, if there were a useNode and useEdge hook. Just like a useState hook, both should allow to update the state of a node and edge.
A possible API could look like this:
const [{ data, position}, setData, setPosition] = useNode<NodeType>(id);
I think it would improve the developer experience and would prevent cluttering the data property of a node with an onChange listener, like on the front page of the documentation.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
 Top Results From Across the Web
Top Results From Across the Web
useEdges API - React Flow
This hook returns the edges. The component that uses this hook re-renders whenever an edge changes.
Read more >File Finder - GitHub
Highly customizable library for building an interactive node-based UI, workflow editor, flow chart or static diagram - File Finder · wbkd/react-flow.
Read more >Edge Functions – Vercel Docs
Vercel's Edge Functions enable you to deliver dynamic, personalized content with the lightweight Edge Runtime. Our Edge Runtime is more performant and ...
Read more >UseNode@1 - Use Node.js ecosystem v1 task | Microsoft Learn
Use this task to find, download, and cache a specified version of Node.js and add it to the PATH. This task also provides...
Read more >DynamicGraph (Cytoscape Javadoc Distribution 2.8.2 API)
Or, implementations may choose to re-use node values as nodes are removed and added again. ... This method is a hook to provide...
Read more > Top Related Medium Post
Top Related Medium Post
No results found
 Top Related StackOverflow Question
Top Related StackOverflow Question
No results found
 Troubleshoot Live Code
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
Top Related Reddit Thread
No results found
 Top Related Hackernoon Post
Top Related Hackernoon Post
No results found
 Top Related Tweet
Top Related Tweet
No results found
 Top Related Dev.to Post
Top Related Dev.to Post
No results found
 Top Related Hashnode Post
Top Related Hashnode Post
No results found

You are right. I think we should separate elements into
nodesandedgesand also split theonElementClickhandler.separating and combining nodes and edges does seem like something you end up doing a little too often, I’m in support of changing it to separate them. but the elements prop would also need to change to accommodate.