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.

useNode, useEdge hooks

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
moklickcommented, Jul 24, 2021

You are right. I think we should separate elements into nodes and edges and also split the onElementClick handler.

1reaction
RickeyWardcommented, Jul 22, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

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