Comments (3)
The getEdges
function returns the store edges: https://github.com/xyflow/xyflow/blob/v11/packages/core/src/hooks/useReactFlow.ts#L37-L40
It will return whatever you passed as edges to the ReactFlow
component. It's not a Connection
or a short form of an edge.
from xyflow.
I see. Thank you!
But i am still kinda confused.
my edges has been set as an empty array const [edges, , onEdgesChange] = useEdgesState([]);
and these are my types
const edgeTypes = {
"custom-edge": CustomEdge,
};
There is nothing else.
I think issue is coming from onConnect
function where besides validation I have
return setEdges(oldEdges => {
// TODO: fix this hardcode later - there should be validation to the target input types and connection to specific one
connection.sourceHandle = "source-0";
connection.targetHandle = "target-0";
// connection has id of source and target handles and also has id of source and target nodes itself
return addEdge({ ...connection, type: "custom-edge" }, oldEdges);
So you can see that it is a connection and not an edge.
This code I got from one of the documentation examples. I think from here
https://reactflow.dev/examples/interaction/validation
Here you can see we set edges based on params argument
const onConnect = useCallback((params) => setEdges((els) => addEdge(params, els)), []);
which have a Connection
type
So instead of setting edges you are setting connections as edges
This cause misunderstandings, because I expect having edges in edges, not connections.
from xyflow.
Hey @maliyshock,
onConnect
gets called when you connect two nodes. As a parameter it gets a connection, because it's not an edge yet. In your case you are using the helper function addEdge
(a simple helper that adds an id and checks if that edge already exists) to create an edge of the connection.
from xyflow.
Related Issues (20)
- autoLayout
- Minimap's onNodeClick doesn't work when using a custom minimap node HOT 2
- RFC - Spatial Queries & Virtualisation in XYFlow HOT 7
- Detaching a node from its parent on drag start produces unexpected positions. (v11 only) HOT 1
- Node gets unselected immediately after selecting. HOT 1
- React flow fails when execute inside a Microfrontend with Module federation
- applyNodeChanges doesn't work with immer HOT 2
- onMouseDown event is not triggered HOT 1
- Marker and node do not touch HOT 1
- Updatable edges: granular control over whether EdgeAnchor appears HOT 2
- `Controls` are just a white rectangle when using `colorMode="dark"` before rendering correctly HOT 2
- Keycode of delete still working when reactFlow is blur HOT 10
- Accessibility: support aria-pressed attributes HOT 1
- Regression Bug: onNodeMouseEnter and onNodeMouseLeave fire more than once since 11.10.0, but was okay in 11.9.4 HOT 2
- The edge path doesn't work well with the CSS scale. HOT 4
- Multiple parent nodes for one child node. HOT 1
- Include 'deletable' property with EdgeProps and NodeProps HOT 1
- export `useVisibleNodeIds` HOT 1
- useOnSelectionChange on change must be memoized now HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xyflow.