Giter VIP home page Giter VIP logo

Comments (8)

peterkogo avatar peterkogo commented on September 16, 2024

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.

DenizUgur avatar DenizUgur commented on September 16, 2024

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.

moklick avatar moklick commented on September 16, 2024

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.

DenizUgur avatar DenizUgur commented on September 16, 2024

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.

DenizUgur avatar DenizUgur commented on September 16, 2024

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

image

what I see on nodes and edges (the ones the graph uses) right before rendering ReactFlow

image

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.

moklick avatar moklick commented on September 16, 2024

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.

DenizUgur avatar DenizUgur commented on September 16, 2024

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.

moklick avatar moklick commented on September 16, 2024

I am glad you could solve it 🙏

from react-flow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.