Comments (8)
One of the things React Flow solves is that you can position your Handles with CSS and RF will do the rest.
You can simply create a custom node with a variable amount of <Handle />
components inside. Position them with CSS. Lean back.
Writing data into the internalsSymbol
will almost always break something.
from react-flow.
Yup, the internalsSybmol
stuff was my attempt to remove the warnings. But regardless, the warnings continue. I'm creating the handles within my nodes during render but I don't understand why I still get these warnings. Since I don't get any warnings if I use setTimeout(setEdges(...), 200)
, I thought that maybe reactflow doesn't know the handles during the next render.
Any additional debug information would go a long way but afaik reactflow doesn't output any debug logs. My theory with this bug/mistake is that handles aren't ready in the next render so the edges fail to connect sometimes. That's why I thought if I can tell reactflow that these handles exists and updateNodeInternals
when they are rendered.
Is there a better way to achieve this? More precisely to inform reactflow about the entire flowchart with handles and all?
from react-flow.
Is this just about warnings or are the edges not rendered correctly? If the rendered output is correct, you don't need to worry about the warning.
In React Flow 12 you will be able to pass a handles
array to a node and supply all information needed to render a flow without measurements from library side (this was necessary to support SSR). You can find all details here: #3764
from react-flow.
Well sometimes they are not rendered but if V12 supports passing on handles then maybe it won't be an issue. I'll upgrade and report back.
from react-flow.
Still continues. Unless I add a delay, it won't clear the warning and this issue affects rendering sparodically.
@moklick How can we debug this further?
the handles and edges I pass to setNodes
and setEdges
what I see on nodes
and edges
(the ones the graph uses) right before rendering ReactFlow
Note
Both images taken at different instances so ids are different
Important
Also note that warning states source for BB68hKjz
updated setNodes
import type { Node as XYFlowNode } from "@xyflow/react"
...
setNodes(
nodes.map((node) => {
if (!node.position) throw new Error("Node does not have a position")
const { x, y } = node.position
const sourceHandles: XYFlowNode["handles"] = Object.keys(node.output).map((pid) => ({
id: pid,
type: "source",
position: Position.Right,
x,
y
}))
const targetHandles: XYFlowNode["handles"] = Object.keys(node.input).map((pid) => ({
id: pid,
type: "target",
position: Position.Left,
x,
y
}))
return {
id: node.id,
type: node.type,
dragHandle: ".node-drag-handle",
position: node.position,
data: { node },
handles: sourceHandles.concat(targetHandles)
}
})
)
from react-flow.
If you want to render a node immediately, you need to set width
and height
attributes.
However I am not sure if that's really the issue here. Could you create a codesandbox for this issue https://new.reactflow.dev ?
from react-flow.
While trying to create the sandbox, I've found the problem. Even thought reactflow knew the handles, I didn't rendered them properly. The updated handles were coming from a different source which made it unavailable during next render. No problems with reactflow, sorry for taking your time :)
from react-flow.
I am glad you could solve it 🙏
from react-flow.
Related Issues (20)
- Allow drag selection inside nodes HOT 11
- Revert to window level event listeners
- [SvelteFlow] panOnScroll shift+scroll horizontal does not work after clicking canvas HOT 6
- `Edge` should accept a generic `type` argument like `Node` HOT 2
- Node Position Changes Cause All Nodes To Disappear HOT 3
- Provide helper to create an edge from edge params or `Connection` HOT 9
- Large Data React-Window Virtualization HOT 7
- prevent outcoming edge from target handle HOT 5
- Edge marker is not dynamically updated HOT 11
- accept array of classes in noPanClassName HOT 5
- snap guidelines HOT 2
- Extra Objects needed HOT 2
- Node position not matching the nodes list and rendered node HOT 5
- defining a fixed markerEnd (or Start) in custom Edge doesn't work? HOT 2
- I face a bug to align center expand and collapse flow HOT 1
- Export type definitions for individual methods and variables of `useSvelteFlow` functionality HOT 4
- add edge mouseenter event HOT 1
- dynamic handle HOT 6
- lavaProps useControl HOT 5
- There is an error in client site
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 react-flow.