Coder Social home page Coder Social logo

xyflow / xyflow Goto Github PK

View Code? Open in Web Editor NEW
21.2K 105.0 1.4K 34.68 MB

React Flow | Svelte Flow - Powerful open source libraries for building node-based UIs with React (https://reactflow.dev) or Svelte (https://svelteflow.dev). Ready out-of-the-box and infinitely customizable.

Home Page: https://xyflow.com

License: MIT License

JavaScript 0.63% CSS 2.67% TypeScript 82.35% Svelte 14.35%
flowchart graph typescript-library react typescript node-based-ui workflow javascript react-flow svelte

xyflow's Introduction

xyflow-header xyflow-header-dark

GitHub License MIT npm downloads npm downloads

Powerful open source libraries for building node-based UIs with React or Svelte. Ready out-of-the-box and infinitely customizable.

React Flow · Svelte Flow · React Flow Pro · Discord


The xyflow mono repo

The xyflow repository is the home of four packages:

We just moved repositories from the @wbkd org to this one. React Flow v11 will remain on the v11 branch. When we have a stable v12, the package name of React Flow will change from reactflow to @xyflow/react.

Commercial usage

Are you using React Flow or Svelte Flow for a personal project? Great! No sponsorship needed, you can support us by reporting any bugs you find, sending us screenshots of your projects, and starring us on Github 🌟

Are you using React Flow or Svelte Flow at your organization and making money from it? Awesome! We rely on your support to keep our libraries developed and maintained under an MIT License, just how we like it. For React Flow you can do that on the React Flow Pro website and for both of our libraries you can do it through Github Sponsors.

Getting started

The best way to get started is to check out the React Flow or Svelte Flow learn section. However if you want to get a sneak peek of how to install and use the libraries you can see it here:

React Flow basic usage

Installation

npm install reactflow

Basic usage

import { useCallback } from 'react';
import ReactFlow, {
MiniMap,
Controls,
Background,
useNodesState,
useEdgesState,
addEdge,
} from 'reactflow';

import 'reactflow/dist/style.css';

const initialNodes = [
{ id: '1', position: { x: 0, y: 0 }, data: { label: '1' } },
{ id: '2', position: { x: 0, y: 100 }, data: { label: '2' } },
];

const initialEdges = [{ id: 'e1-2', source: '1', target: '2' }];

function Flow() {
const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);

const onConnect = useCallback((params) => setEdges((eds) => addEdge(params, eds)), [setEdges]);

return (
  <ReactFlow
    nodes={nodes}
    edges={edges}
    onNodesChange={onNodesChange}
    onEdgesChange={onEdgesChange}
    onConnect={onConnect}
  >
    <MiniMap />
    <Controls />
    <Background />
  </ReactFlow>
);
}

export default Flow;
Svelte Flow basic usage

Installation

npm install @xyflow/svelte

Basic usage

<script lang="ts">
import { writable } from 'svelte/store';
import {
  SvelteFlow,
  Controls,
  Background,
  BackgroundVariant,
  MiniMap,
} from '@xyflow/svelte';

import '@xyflow/svelte/dist/style.css'

const nodes = writable([
  {
    id: '1',
    type: 'input',
    data: { label: 'Input Node' },
    position: { x: 0, y: 0 }
  },
  {
    id: '2',
    type: 'custom',
    data: { label: 'Node' },
    position: { x: 0, y: 150 }
  }
]);

const edges = writable([
  {
    id: '1-2',
    type: 'default',
    source: '1',
    target: '2',
    label: 'Edge Text'
  }
]);
</script>

<SvelteFlow
{nodes}
{edges}
fitView
on:nodeclick={(event) => console.log('on node click', event)}
>
<Controls />
<Background variant={BackgroundVariant.Dots} />
<MiniMap />
</SvelteFlow>

The xyflow team

React Flow and Svelte Flow are maintained by the team behind xyflow. If you need help or want to talk to us about a collaboration, reach out through our contact form or by joining our Discord Server.

License

React Flow and Svelte Flow are MIT licensed.

xyflow's People

Contributors

alvarezgarcia avatar andreyworkspace avatar andys8 avatar ark-kun avatar bcakmakoglu avatar chrtze avatar dependabot-preview[bot] avatar dependabot[bot] avatar elringus avatar geoffreyjohospartner avatar hayleigh-dot-dev avatar himself65 avatar iamakulov avatar jackfishwick avatar jasonpul avatar joeyballentine avatar justrhysism avatar lounsbrough avatar mahdi-esbati avatar moklick avatar namack avatar neo avatar peterkogo avatar rundevelopment avatar sec-ant avatar shaman123 avatar silkservice avatar spencerwhitehead7 avatar verluci avatar zcmgyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xyflow's Issues

rollup: plugins output

Create extra output for plugins folder so that the could get imported like:

import { MiniMap, Controls } from 'react-flow/plugins'

onSelectionChange prop missing

The README specifies an onSelectionChange prop for the ReactFlow component. However it doesn't seem to be present in the ReactFlowProps interface at /react-flow-renderer/dist/container/ReactFlow/index.d.ts
Nevermind. Had to fetch and rebuild package.

Support for text on Edges

Hi, love the repo and was just looking for something like this to help my team explain lots of scenarios.

However I'd like to ask if there's support for Text on the Edges coming soon so that I can explain decision trees without having to add an additional two more nodes for "YES" and "NO"

Cheers

isInteractive is preventing custom click handlers

I have a use-case where I want to disable the graph from being changed. (E.g: nodes being dragged) but I still want to be able to click them to trigger UI changes elsewhere (E.g: a sidebar being opened with node information).

I believe is-interactive is a good solution for this but the implementation of it is causing some issues. Because it's setting pointer-events: none on the nodeWrapper, click handlers in custom nodes are not being triggered. I can override it by setting pointer-events: all on the inner element that I want to attach a click listener to but for some reason this prevents panning, zooming, ... all interactivity when hovering on a node.

Steps to reproduce:

  • Disable interactivity
  • Adjust a node's style to have pointer-events: all
  • Notice that only on this node you will not be able to zoom/pan/...

My suggestion is to add a flag that only disables the dragging / modification of the graph but keeps all attached listeners active.

Another option could be to drive the interactivity from CSS and be able determine as the implementor which pointer-events: none | all | auto are getting set based on the class given to the parent graph.

Connection curve preview generates always generates from "source" handle

Hi @moklick

I noticed today after updating to the latest release that when connecting nodes from target to source rather than source to target the curve preview is attached to the node's source rather than the target.

This can be replicated in the example pages by clicking on the target handle for the You can find the docs on Github node and trying to connect to This is a default node node.

You can see the preview is attached to the You can find the docs on Github node's source handle, rather than the target handle.

This doesn't appear to impact the result once you create it. It only makes the preview incorrect.

89390768-E079-4EB4-A7D6-BE3A9ACFDD5B

Bug: can't move nodes with Safari

ReferenceError: Can't find variable: TouchEvent

Another Safari quirk is that starting a node connection kills react (white screen).

State: nodes incorrectly positioned on rerender

i calculate node positioning from my server and pass those nodes directly to a Graph component.

when my nodes initially render, they are positioned correctly, but if i later pass a new set of nodes, the positioning is wrong -- the tree appears much larger and less dense, it's as if the x/y position for each node gets multiplied by some number. if i then refresh my page, my nodes appear positioned correctly again.

i understand react-flow manages internal position state - i'm wondering if something isn't getting cleared on rerender?

i suspect i could get around the problem if i had the ability to reset position state before passing Graph new elements.

in case you aren't sure what's going on, i'll keep poking to see if i can identify the root cause.

thanks!

Where to put the onConnect callback

Right now the onConnect gets added to the store. We can't pass it through because it's used in the Handle component which can be used by the users directly. Is there a better place where we could store the callback? Should we create a context for this kind of stuff?

Draggable.js error when graph is not visible

Hi there, I was doing some experimentation with react-flow in a newly created CRA and ran into a problem while testing the examples in a new codebase.

It turns out that not setting a height on the body and including the graph causes Draggable.js to break because the graph is not rendered which is quite confusing.

The error I get is:

graph loaded: {fitView: ƒ, zoomIn: ƒ, zoomOut: ƒ}
Draggable.js:378 Uncaught RangeError: Invalid array length
    at Function.from (<anonymous>)
    at createGridDots (Draggable.js:378)
    at Draggable.js:378
    at renderWithHooks (react-dom.development.js:14803)
    at updateFunctionComponent (react-dom.development.js:17034)
    at updateSimpleMemoComponent (react-dom.development.js:16972)
    at beginWork (react-dom.development.js:18687)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at beginWork$1 (react-dom.development.js:23203)
    at performUnitOfWork (react-dom.development.js:22154)
    at workLoopSync (react-dom.development.js:22130)
    at performSyncWorkOnRoot (react-dom.development.js:21756)
    at react-dom.development.js:11089
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11084)
    at flushSyncCallbackQueue (react-dom.development.js:11072)
    at flushPassiveEffectsImpl (react-dom.development.js:22883)
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushPassiveEffects (react-dom.development.js:22820)
    at react-dom.development.js:22699
    at workLoop (scheduler.development.js:597)
    at flushWork (scheduler.development.js:552)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:164)
createGridDots @ Draggable.js:378
(anonymous) @ Draggable.js:378
renderWithHooks @ react-dom.development.js:14803
updateFunctionComponent @ react-dom.development.js:17034
updateSimpleMemoComponent @ react-dom.development.js:16972
beginWork @ react-dom.development.js:18687
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
beginWork$1 @ react-dom.development.js:23203
performUnitOfWork @ react-dom.development.js:22154
workLoopSync @ react-dom.development.js:22130
performSyncWorkOnRoot @ react-dom.development.js:21756
(anonymous) @ react-dom.development.js:11089
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushSyncCallbackQueueImpl @ react-dom.development.js:11084
flushSyncCallbackQueue @ react-dom.development.js:11072
flushPassiveEffectsImpl @ react-dom.development.js:22883
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushPassiveEffects @ react-dom.development.js:22820
(anonymous) @ react-dom.development.js:22699
workLoop @ scheduler.development.js:597
flushWork @ scheduler.development.js:552
performWorkUntilDeadline @ scheduler.development.js:164
index.js:1 The above error occurred in one of your React components:
    in Unknown
    in div
    in Unknown (created by ReactFlow)
    in StoreProvider (created by ReactFlow)
    in div (created by ReactFlow)
    in ReactFlow (at Graph.js:44)
    in RichGraph (at App.js:10)
    in App (at src/index.js:33)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
console.<computed> @ index.js:1
logCapturedError @ react-dom.development.js:19527
logError @ react-dom.development.js:19564
update.callback @ react-dom.development.js:20708
callCallback @ react-dom.development.js:12490
commitUpdateQueue @ react-dom.development.js:12511
commitLifeCycles @ react-dom.development.js:19883
commitLayoutEffects @ react-dom.development.js:22803
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
commitRootImpl @ react-dom.development.js:22541
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
commitRoot @ react-dom.development.js:22381
finishSyncRender @ react-dom.development.js:21807
performSyncWorkOnRoot @ react-dom.development.js:21793
(anonymous) @ react-dom.development.js:11089
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushSyncCallbackQueueImpl @ react-dom.development.js:11084
flushSyncCallbackQueue @ react-dom.development.js:11072
flushPassiveEffectsImpl @ react-dom.development.js:22883
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushPassiveEffects @ react-dom.development.js:22820
(anonymous) @ react-dom.development.js:22699
workLoop @ scheduler.development.js:597
flushWork @ scheduler.development.js:552
performWorkUntilDeadline @ scheduler.development.js:164
Draggable.js:378 Uncaught RangeError: Invalid array length
    at Function.from (<anonymous>)
    at createGridDots (Draggable.js:378)
    at Draggable.js:378
    at renderWithHooks (react-dom.development.js:14803)
    at updateFunctionComponent (react-dom.development.js:17034)
    at updateSimpleMemoComponent (react-dom.development.js:16972)
    at beginWork (react-dom.development.js:18687)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at beginWork$1 (react-dom.development.js:23203)
    at performUnitOfWork (react-dom.development.js:22154)
    at workLoopSync (react-dom.development.js:22130)
    at performSyncWorkOnRoot (react-dom.development.js:21756)
    at react-dom.development.js:11089
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11084)
    at flushSyncCallbackQueue (react-dom.development.js:11072)
    at flushPassiveEffectsImpl (react-dom.development.js:22883)
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushPassiveEffects (react-dom.development.js:22820)
    at react-dom.development.js:22699
    at workLoop (scheduler.development.js:597)
    at flushWork (scheduler.development.js:552)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:164)

Including the CSS from the example solves this issue:

html,
body {
  margin: 0;
}

html,
body,
#root {
  height: 100%;
}

#root {
  display: flex;
  flex-direction: column;
}

Non-Interactive Mode

When the graph is not interactive it should be possible to pan while pointer is above a node or edge.

Export project function

it would be nice to have a function for transforming pixel coordinates into react-flows internal coordinates (with scale)

Typescript error for <Handle> prop

I'm using <Handle> within a custom node component and I get the following Typescript error:

TS2322: Type '"top"' is not assignable to type 'Position'.

Using 1.3.5

Background Component

Instead of configuring the background via the React Flow component prop types we should export a Background component like the MiniMap or Controls.

Getting zoom level and other state in child components

When building additional components outside of this project (e.g.: a different implementation for background / grid rendering) there currently is no way to access the state because it's not being exported.

I'm not familiar with easy-peasy and perhaps there is a way but I was unable to find it.

A simple solution would be to export the useStoreState from store/hooks to be able to pull in state from react-flow.

What are your thoughts on this?

Validate Connection

We should have an optional callback for the handles that validates if a connection is valid. We should then toggle classes like hover, valid on the handles in order to be able to style handles depending on the validation status.

Contribute with lock board plugin

Hi WebKid team,
first of all thanks for this incredible library, I was looking for something like this to use on a shared board.

I've checked the code of plugins and the useStoreState and useStoreActions hooks in order to create a button that locks the board, using the setInteractivity function and is working (at the time as a button on controls plugin but I think that might be better as a separated plugin).

If you think that this could be a useful addition, I want to know which are the steps to follow to contribute.

Thanks again for all this tremendous work.

ConnectionLine occasionally throws an error

Hi,

I'm having an issue when trying to connect a node.

This specific node was loaded over http from a hook (useEffect) and only has a source port.
When I try to draw an edge I sometimes receive an error immediately and other times it manages to render the line but after a certain amount of ticks throws the same error.

I traced the issue back to this line:

  const sourceHandle = handleId
    ? sourceNode.__rg.handleBounds[handleKey].find((d: HandleElement) => d.id === handleId)
    : sourceNode.__rg.handleBounds[handleKey][0];

It appears that handleBounds[handleKey] ends up being undefined causing this to break.

I'm updating the elements in the graph using setElements

Changing the implementation to use optional chaining seems to fix the issue but I'm not sure what the side effects might be.

  const sourceHandle = handleId
    ? sourceNode.__rg.handleBounds[handleKey].find((d: HandleElement) => d.id === handleId)
    : sourceNode.__rg.handleBounds[handleKey]?.[0];

Full stack trace:

connectionSourceId 05000d8f-2eea-4f08-aeb8-d8fc9b2dbf77
index.tsx:33 sourceIdSplitted ["05000d8f-2eea-4f08-aeb8-d8fc9b2dbf77"]
index.tsx:30 connectionSourceId 05000d8f-2eea-4f08-aeb8-d8fc9b2dbf77
index.tsx:33 sourceIdSplitted ["05000d8f-2eea-4f08-aeb8-d8fc9b2dbf77"]
index.tsx:30 connectionSourceId 05000d8f-2eea-4f08-aeb8-d8fc9b2dbf77
index.tsx:33 sourceIdSplitted ["05000d8f-2eea-4f08-aeb8-d8fc9b2dbf77"]
Uncaught TypeError: Cannot read property '0' of undefined
    at ConnectionLine (index.tsx:53)
    at renderWithHooks (react-dom.development.js:14803)
    at updateFunctionComponent (react-dom.development.js:17034)
    at beginWork (react-dom.development.js:18610)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at beginWork$1 (react-dom.development.js:23203)
    at performUnitOfWork (react-dom.development.js:22154)
    at workLoopSync (react-dom.development.js:22130)
    at performSyncWorkOnRoot (react-dom.development.js:21756)
    at react-dom.development.js:11089
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11084)
    at flushSyncCallbackQueue (react-dom.development.js:11072)
    at flushPassiveEffectsImpl (react-dom.development.js:22883)
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushPassiveEffects (react-dom.development.js:22820)
    at react-dom.development.js:22699
    at workLoop (scheduler.development.js:597)
    at flushWork (scheduler.development.js:552)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:164)
ConnectionLine @ index.tsx:53
renderWithHooks @ react-dom.development.js:14803
updateFunctionComponent @ react-dom.development.js:17034
beginWork @ react-dom.development.js:18610
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
beginWork$1 @ react-dom.development.js:23203
performUnitOfWork @ react-dom.development.js:22154
workLoopSync @ react-dom.development.js:22130
performSyncWorkOnRoot @ react-dom.development.js:21756
(anonymous) @ react-dom.development.js:11089
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushSyncCallbackQueueImpl @ react-dom.development.js:11084
flushSyncCallbackQueue @ react-dom.development.js:11072
flushPassiveEffectsImpl @ react-dom.development.js:22883
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushPassiveEffects @ react-dom.development.js:22820
(anonymous) @ react-dom.development.js:22699
workLoop @ scheduler.development.js:597
flushWork @ scheduler.development.js:552
performWorkUntilDeadline @ scheduler.development.js:164
index.js:1 The above error occurred in the <ConnectionLine> component:
    in ConnectionLine
    in g
    in svg
    in Unknown
    in div
    in Unknown (created by ReactFlow)
    in StoreProvider (created by ReactFlow)
    in div (created by ReactFlow)
    in ReactFlow (at Test/index.js:107)
    in BasicFlow (at src/index.js:89)
    in Route (at src/index.js:89)
    in Switch (at src/index.js:87)
    in Router (created by BrowserRouter)
    in BrowserRouter (at src/index.js:84)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
console.<computed> @ index.js:1
r @ react_devtools_backend.js:6
logCapturedError @ react-dom.development.js:19527
logError @ react-dom.development.js:19564
update.callback @ react-dom.development.js:20708
callCallback @ react-dom.development.js:12490
commitUpdateQueue @ react-dom.development.js:12511
commitLifeCycles @ react-dom.development.js:19883
commitLayoutEffects @ react-dom.development.js:22803
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
commitRootImpl @ react-dom.development.js:22541
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
commitRoot @ react-dom.development.js:22381
finishSyncRender @ react-dom.development.js:21807
performSyncWorkOnRoot @ react-dom.development.js:21793
(anonymous) @ react-dom.development.js:11089
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushSyncCallbackQueueImpl @ react-dom.development.js:11084
flushSyncCallbackQueue @ react-dom.development.js:11072
flushPassiveEffectsImpl @ react-dom.development.js:22883
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushPassiveEffects @ react-dom.development.js:22820
(anonymous) @ react-dom.development.js:22699
workLoop @ scheduler.development.js:597
flushWork @ scheduler.development.js:552
performWorkUntilDeadline @ scheduler.development.js:164
scheduler.development.js:178 Uncaught TypeError: Cannot read property '0' of undefined
    at ConnectionLine (index.tsx:53)
    at renderWithHooks (react-dom.development.js:14803)
    at updateFunctionComponent (react-dom.development.js:17034)
    at beginWork (react-dom.development.js:18610)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at beginWork$1 (react-dom.development.js:23203)
    at performUnitOfWork (react-dom.development.js:22154)
    at workLoopSync (react-dom.development.js:22130)
    at performSyncWorkOnRoot (react-dom.development.js:21756)
    at react-dom.development.js:11089
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11084)
    at flushSyncCallbackQueue (react-dom.development.js:11072)
    at flushPassiveEffectsImpl (react-dom.development.js:22883)
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushPassiveEffects (react-dom.development.js:22820)
    at react-dom.development.js:22699
    at workLoop (scheduler.development.js:597)
    at flushWork (scheduler.development.js:552)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:164)

I've been trying to debug this issue by pulling the source code and linking my application (in typescript) to the library using yarn link and "react-flow-renderer": "file:../react-flow/", but with both I seem to be unable to import the typings causing it to not work anymore and I can't seem to figure out why it works fine when using the node_modules version and it stops working when using the linked version. Normal imports are working just fine but when importing certain typings it breaks. It's basically everything that is being exported from src/types/index.ts

See:
Schermafbeelding 2020-05-27 om 11 33 48

I can split this up into two issues if this second one is actually an issue and not some misconception from my side.

Background Pattern

Add a grid background pattern that scales and pans with the users actions

Layout Algorithm

It would be nice to have an automatic layout like breadth first tree or something like that we could use to order the graph

Bezier connection line not generating correct when connecting diagonally

If you connect a node with handles left and right, to a node with handles facing up and down the bezier curve doesn't generate correct for each use case.

e.g. Connecting TOP to LEFT handles generates correctly, but connecting RIGHT to BOTTOM handles generates a curve the same as LEFT to TOP

image

Minimap Zoom and Pan

It would be nice if we could pan and zoom inside the mini map to control the flow pane.

snap to grid is not behaving correctly

Hi again,

When using snap to grid everything works as expected on the initial zoom level scale of 1. If you zoom in by a fraction (e.g.: scale 1.2) the grid snapping is not working correctly. As soon as you hit scale(2) it starts snapping back to the grid but with a double offset from your mouse position. I believe the reason is that the grid snapping is scaling the snapping based on the current zoom factor which is not required. The node's translation is being scaled by the parent container (the graph) and should not be manually scaled to the zoom factor.

See this loom video for more context: https://www.loom.com/share/e1b71b244f33436c91d29ef156f6c12c

Controls

Add zoom and fit view controls

Difference between click and drag

I want to open model when user click a node. But if the user drag the node the model will pop up. Any suggestion on what can I do?

State: isInitialized

We need an initialized state internally that should be true after first render happened. We should not call onLoad until isInitialized is true.

Right now we can't call fitView on load for example because the graph is still empty.

Need help understanding the raw Implementation

Hey, I was trying to create a visual scripting framework using node graphs and react when I stumbled upon your library. It was exactly what I was looking for, however, it had such high abstraction that I had to stop using it. I tried implementing one on my own but ran into various issues and thus I'm stuck.

Can you help me understand what libraries are you under the hood and for what purpose? I'd like the create my own version of it. Also, any helpful resources towards understanding the implementation would be greatly appreciated :))

TypeError: Cannot read property '0' of null

When I click on the following spot, the app crashes with the error:

TypeError: Cannot read property '0' of null

Screenshot 2020-05-06 at 09 30 18

I can reproduce the error in Chrome and Firefox in the two Examples "Rich" and "CustomNode" but only on the green boxes.

Sizing the Controls

Not able to change the size and positioning of the Control buttons. Any idea how to do it?

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.