-
#4846
75017939
Thanks @moklick! - Make it possible to use expandParent with immer and other immutable helpers -
#4865
2c4acc2b
Thanks @moklick! - Add group node to BuiltInNode type. Thanks @sjdemartini! -
#4877
9a8309da
Thanks @peterkogo! - Fix intersections for nodes with origins other than [0,0]. Thanks @gmvrpw! -
#4844
6f11e552
Thanks @moklick! - Allow custom data-testid for ReactFlow component -
#4816
43aa52a8
Thanks @moklick! - Type isValidConnection prop correctly by passing EdgeType -
#4855
106c2cf8
Thanks @mhuggins! - Support passingpath
element attributes toBaseEdge
component. -
#4862
adf4fb4e
Thanks @bcakmakoglu! - Prevent default scrolling behavior when nodes or a selection is moved with an arrow key press. -
#4875
41d4743a
Thanks @peterkogo! - Prevent unnecessary rerenders of edges when resizing the flow. -
#4826
5f90acda
Thanks @chrtze! - Forward ref of the div inside Panel components. -
Updated dependencies [
d60331e6
]:- @xyflow/[email protected]
-
#4789
358eb355
Thanks @peterkogo! - Support key combinations which include '+' (e.g., 'Control++' resolves to the combination 'Control' and '+'). -
#4796
73402779
Thanks @Aki-7! - Fix number of issues connected to batching node & edge updates. -
#4790
2fa9a920
Thanks @peterkogo! - Fix node dragging & resizing while zooming on flow that does not cover whole browser window. -
#4782
323e1b35
Thanks @peterkogo! - Fix node intersections in nested flow. -
Updated dependencies [
2fa9a920
,323e1b35
]:- @xyflow/[email protected]
-
#4772
7f670ab0
Thanks @mistic! - Splits exports field in package.json to support an explicit resolution for browser, node and default to resolve issues with webpack esm module resolution. -
Updated dependencies [
7f670ab0
]:- @xyflow/[email protected]
-
#4755
005ae1c0
Thanks @peterkogo! - Add module to exports in package.json. This should resolve possible issues with Webpack ESM Module Resolution. -
#4730
2c590b90
Thanks @peterkogo! - Fixed rare crash while dragging -
Updated dependencies [
005ae1c0
,2c590b90
]:- @xyflow/[email protected]
- #4722
e816bb69
Thanks @moklick! - Fix internal behaviour that mutated user nodes which led to an issue with Redux and immer
-
#4670
b056564c
Thanks @peterkogo! - Fix initialfitView
not working correctly fornodeOrigin
other than [0,0] -
#4670
b056564c
Thanks @peterkogo! - ImprovefitView
to respect clamped node positions based onnodeExtent
-
#4653
02390f99
Thanks @bcakmakoglu! - Calculate viewport dimensions infitView
instead of using stored dimensions. Fixes #4652 -
Updated dependencies [
99ba64ac
,b056564c
]:- @xyflow/[email protected]
- #4477
d5592e75
Thanks @peterkogo! - AddgetNodesBounds
touseReactFlow
/useSvelteFlow
hook as the new recommended way of determining node bounds.
-
#4630
4347269f
Thanks @moklick! - Fix<Minimap />
only displaying nodes when providingonNodesChange
. -
#4572
d9563505
Thanks @peterkogo! - Improve handling of global and individualnodeExtent
s. Nodes will never render outside of specified extents. -
Updated dependencies [
d5592e75
,d9563505
]:- @xyflow/[email protected]
-
#4619
a7eb7c2d
Thanks @moklick! - align background pattern with snap grid -
#4611
2aaa709c
Thanks @moklick! - make onViewportChange a dynamic prop -
Updated dependencies [
2aaa709c
]:- @xyflow/[email protected]
- #4574
b65aed19
Thanks @bcakmakoglu! - AddgetHandleConnections
helper touseReactFlow
&useSvelteFlow
-
#4594
5138d90b
Thanks @peterkogo! - Fixed reconnecting edges with loose connectionMode -
#4603
12dbe125
Thanks @moklick! - use correct index when using setNodes for inserting -
Updated dependencies [
5138d90b
,12dbe125
]:- @xyflow/[email protected]
-
#4568
c3e62782
Thanks @peterkogo! - Only display grab cursor when panOnDrag is on left mouse button -
#4567
cc75c29f
Thanks @peterkogo! - Fix internal type of edges in store -
Updated dependencies [
c3e62782
]:- @xyflow/[email protected]
-
#4555
24e87e39
Thanks @peterkogo! - Added final connection state as a function parameter to onReconnectEnd -
#4554
cca11ea1
Thanks @peterkogo! - Added optional selector for useConnection hook -
#4549
99733c01
Thanks @moklick! - feat(onConnectEnd): pass connectionState param
-
#4550
41981970
Thanks @moklick! - fix(fitView): only trigger for resize observer -
#4501
ec64b572
Thanks @jeffgord! - fix(background): use offset prop correctly for dots variant -
#4548
692e6440
Thanks @peterkogo! - Replaced algorithm used for searching close handles while connecting -
#4547
fdff601d
Thanks @moklick! - chore(react): re-export Handle type -
Updated dependencies [
b63a3734
,24e87e39
,692e6440
,559d4926
,4ecfd7e1
,e7ef328f
,99733c01
]:- @xyflow/[email protected]
-
#4480
aae526f4
Thanks @peterkogo! - fix(dragging) nodeExtent breaks dragging nodes in subflows -
#4498
7a6e9e30
Thanks @peterkogo! - fix(pane) only capture pointer after a valid selection has started, fixes #4492
- Updated dependencies [
543c0939
,89cd677b
,c253c7c5
]:- @xyflow/[email protected]
-
#4446
80baf53b
Thanks @moklick! - fix(resizer): export types -
#4450
18a12661
Thanks @moklick! - fix(selection): dont trigger onSelectionEnd on click -
Updated dependencies [
80baf53b
,4cccd06a
]:- @xyflow/[email protected]
-
#4434
1bda2451
Thanks @moklick! - fix(selection): handle pointer capture for selectionOnDrag -
#4432
d2da5765
Thanks @moklick! - refactor(useConnection): return internal node, add node generic -
Updated dependencies [
d2da5765
]:- @xyflow/[email protected]
React Flow 12 is finally out! With a new package name @xyflow/react
!
- SSR / SSG: you can define
width
,height
andhandles
for the nodes. This makes it possible to render a flow on the server and hydrate on the client: SSR guide- Details: In v11,
width
andheight
were set by the library as soon as the nodes got measured. This still happens, but we are now usingmeasured.width
andmeasured.height
to store this information. In the previous versions there was always a lot of confusion aboutwidth
andheight
. It’s hard to understand, that you can’t use it for passing an actual width or height. It’s also not obvious that those attributes get added by the library. We think that the new implementation solves both of the problems:width
andheight
are optional attributes that can be used to define dimensions and the measured dimensions are stored inmeasured
.
- Details: In v11,
- Reactive Flows: The new hooks
useHandleConnections
anduseNodesData
and the newupdateNode
andupdateNodeData
functions can be used for managing the data flow between your nodes: computing flows guide- Details: Working with reactive flows is super common. You update node A and want to react on those changes in the connected node B. Until now everyone had to come up with a custom solution. With this version we want to change this and give you performant helpers to handle this. If you are excited about this, you can check out this example:
- Dark mode and css variables: React Flow now comes with a built-in dark mode, that can be toggled by using the new
colorMode
prop (”light”, “dark” or “system”): dark mode example- Details: With this version we want to make it easier to switch between dark and light modes and give you a better starting point for dark flows. If you pass colorMode=”dark”, we add the class name “dark” to the wrapper and use it to adjust the styling. To make the implementation for this new feature easier on our ends, we switched to CSS variables for most of the styles. These variables can also be used in user land to customize a flow.
There is more! Besides the new main features, we added some minor things that were on our list for a long time. We also started to use TS docs for better docs. We already started to add some docs for some types and hooks which should improve the developer experience.
useConnection
hook: With this hook you can access the ongoing connection. For example, you can use it for colorizing handles styling a custom connection line based on the current start / end handles.- Controlled
viewport
: This is an advanced feature. Possible use cases are to animate the viewport or round the transform for lower res screens for example. This features brings two new props:viewport
andonViewportChange
. ViewportPortal
component: This makes it possible to render elements in the viewport without the need to implement a custom node.onDelete
handler: We added a combined handler foronDeleteNodes
andonDeleteEdges
to make it easier to react to deletions.onBeforeDelete
handler: With this handler you can prevent/ manage deletions.isValidConnection
prop: This makes it possible to implement one validation function for all connections. It also gets called for programmatically added edges.autoPanSpeed
prop: For controlling the speed while auto panning.- Background component: add
patternClassName
prop to be able to style the background pattern by using a class name. This is useful if you want to style the background pattern with Tailwind for example. onMove
callback gets triggered for library-invoked viewport updates (like fitView or zoom-in)deleteElements
now returns deleted nodes and deleted edges- add
origin
attribute for nodes - add
selectable
attribute for edges - Node Resizer: child nodes don't move when the group is resized, extent and expand is recognized correctly
- Correct types for
BezierEdge
,StepEdge
,SmoothStepEdge
andStraightEdge
components - New edges created by the library only have
sourceHandle
andtargetHandle
attributes when those attributes are set. (We used to passsourceHandle: null
andtargetHandle: null
) - Edges do not mount/unmount when their z-index change
- connection line knows about the target handle position so that the path is drawn correctly
nodeDragThreshold
is 1 by default instead of 0- a better selection box usability (capture while dragging out of the flow)
- add
selectable
,deletable
,draggable
andparentId
toNodeProps
- add a warning when styles not loaded
- add
paneDistanceClick
prop (max distance between mousedown/up that will trigger a click) - returned nodes in
onNodeDragStop
are set todragging=false
- return Promises for
setViewport
,fitView
,fitBounds
andzoomTo
to be able to await viewport update
- add
autoPanSpeed
prop
useConnection
returnsConnectionState
withtoNode
andtoHandle
- add
toNode
andtoHandle
to custom connection line props - node origin is part of position absolute
- refactor connection handling
- fix
window
bug for SSR for real
- fix
window
bug for SSR
⚠️ renameupdateEdge
toreconnectEdge
and realted APIs #4373- revise selection usability (capture while dragging out of the flow)
- use correct end handle position when drawing a connection lines
- determine correct end positions for connection lines
- fix node origin bug
- add
updateEdge
andupdateEdgeData
helpers touseReactFlow
- enable dynamic edge label updates
- prevent zooming on mobile if zoomOnPinch is false
- add straight edge to path built-in-types
- abort drag when multiple touches are detected
- update internals on node resizer updates
- re-observe node when
node.hidden
is toggled - update
updateNodeData
argument type - thanks @ogroppo - add
selectable
,deletable
anddraggable
to node and edge props - add
parentId
to node props - fix parent node lookup in
evaluateAbsolutePosition
- thanks @lcsfort
- don't show nodeTypes warning if not necessary you've created a new nodeTypes or edgeTypes
- add node resizer styles to base.css
- remove
HandleComponentProps
type, only exportHandleProps
type - add warning when styles not loaded
- fix broken
defaultNodes
- add string array to
UpdateNodeInternals
thanks @DenizUgur - pinch zoom on windows
- drag for touch devices
- return user node in node event handlers
- cleanup
useReactFlow
- export
KeyCode
andAlign
type - remove
Instance
in favour ofReactFlowInstance
type
- fix batching for
setNodes
,updateNode
,updateNodeData
etc. - fix
useNodesInitialized
- re-observe nodes when using
onlyRenderVisibleElements={true}
- use correct positions for intersection helpers
- fix minimap interaction for touch devices
- pass user nodes to
onSelectionChange
instead of internal ones to work with Redux - call
onEnd
in XYResizer thanks @tonyf - cleanup
getPositionWithOrigin
usage - use
setAttributes
flag for dimension change whenwidth
/height
should be set - use
replace: false
as the default forupdateNode
function
- fix hidden nodes
- use
direction=ltr
for outer wrapper to support rtl sites - allow pinch zoom even if
preventScrolling=false
- export node and edge change related types
- only trigger dimensions updates when changes detected
- rename
node.parentNode
tonode.parentId
- rename node.computed to node.measured
- remove positionAbsolute from
node.computed
- new helpers:
useInternalNode
hook,getInternalNode
function
- remove
internalsSymbol
(now called internals and only available for internal nodes) - handle parentExpand on library side instead of applyChanges
- new type
InternalNode
- fix useNodesData: handle invalid node id thanks @saswatax
- fix forwardRef: use custom fixForwardRef function
- refactor intersection helpers to use passed node value
- fix
ref
prop forReactFlow
andHandle
component - unify
Edge
andNode
type handling - fix safari: prevent selection of viewport
- fix
useNodesData
hook to prevent re-renderings - fix edges: allow start at 0,0
useNodesData
not only returns data objects but also the type and the id of the node- status class names for Handle components are slightly different. It's now "connectingfrom" and "connectingto" instead of "connecting"
- better cursor defaults for the pane, nodes and edges
disableKeyboardA11y
now also disables Enter and Escape for selecting/deselecting nodes and edges- fix bug where users couldn't drag a node after toggle nodes
hidden
attribute - add
initialWidth
andinitialHeight
node attributes for specifying initial dimensions for ssr - fix
NodeResizer
when used in combination withnodeOrigin
- a better
NodeResizer
that works with subflows. Child nodes do not move when parent node gets resized and parent extent is taken into account - refactor
setNodes
batching - re-measure nodes when necessary
- don't trigger drag start / end when node is not draggable
- selection box is not interrupted by selectionKey being let go
- fix
OnNodeDrag
type - do not use fallback handle if a specific id is being used
- fix
defaultEdgeOptions
markers not being applied - fix
getNodesBounds
and add second param for passing options - fix
expandParent
for child nodes
- add second option param to
screenToFlowPosition
for configuring ifsnapToGrid
should be used
- pass
Node
/Edge
types to changes thanks @FelipeEmos - use position instead of positionAbsolute for
getNodesBounds
- infer types for
getIncomers
,getOutgoers
,updateEdge
,addEdge
andgetConnectedEdges
thanks @joeyballentine - refactor handles: prefix with flow id for handling nested flows
- add comments for types like
ReactFlowProps
orNode
for a better developer experience
- fix
deleteElements
- refactor internal
applyChanges
- batch
setNodes
andsetEdges
fromuseReactFlow
- add
aria-label
prop for<Controls />
- fix applyChanges: handle multi changes for one node, deletions and expandParent
- use
XYResizer
from @xyflow/system - add unit tests for
applyNodeChanges
andapplyEdgeChanges
- fix applyChanges: handle empty flows + addNodes/addEdges closes
- cleanup exports
- fix edges styles when using base.css
- fix connection line rendering
- fix multi handle
- fix edge rendering
React Flow v12 is coming soon! We worked hard over the past months and tried to make as few breaking changes as possible (there are some). We are in no rush to release v12, so we’d be happy to hear any early feedback so we can adjust the API or redefine new features before launching stable v12. 🚀 The big topics for this version are:
- Support for SSG/ SSR: you can now render flows on the server
- Reactive flows: new hooks and helper functions to simplify data flows
- Dark mode: a new base style and easy way to switch between built in color modes
Svelte Flow had a big impact on this release as well. While combing through each line of React Flow, we created framework agnostic helpers, found bugs, and made some under the hood improvements. All of these changes are baked into the v12 release as a welcome side-effect of that launch. 🙌🏻 We also improved the performance for larger flows with the help of Ivan.
Before you can try out the new features, you need to do some minor updates:
- A new npm package name: Our name changed from
reactflow
to@xyflow/react
and the main component is no longer a default, but a named import:- v11:
import ReactFlow from 'reactflow';
- v12:
import { ReactFlow } from '@xyflow/react';
- v11:
- Node attribute “computed”: All computed node values are now stored in
node.computed
- v11:
node.width
,node.height
,node.positionAbsolute
- v12:
node.computed.width
,node.computed.height
andnode.computed.positionAbsolute
. (node.width
/node.height
can now be used for SSG)
- v11:
- Updating nodes: We are not supporting node updates with object mutations anymore. If you want to update a certain attribute, you need to create a new node.
- v11:
setNodes((nds) => nds.map((node) => { node.hidden = true; return node; }) );
- v12:
setNodes((nds) => nds.map((node) => ({ ...node, hidden: true, })) );
- v11:
- NodeProps:
posX
/posY
is now calledpositionAbsoluteX
/positionAbsoluteY
- Typescript only: We simplified types and fixed issues about functions where users could pass a
NodeData
generic. The new way is to define your own node type for the whole app and then only use that one. The big advantage of this is, that you can have multiple node types with different data structures and always be able to distinguish by checking thenode.type
attribute.- v11:
applyNodeChange<NodeData, NodeType>
- v12:
type MyNodeType = Node<{ value: number }, ‘number’> | Node<{ value: string }, ‘text’>; applyNodeChange<MyNodeType>
- affected functions:
useNodes
,useNodesState
,useEdgesState
,applyNodeChange
,onInit
,applyEdgeChanges
,MiniMapProps
- v11:
- Removal of deprecated functions:
getTransformForBounds
(new name:getViewportForBounds
),getRectOfNodes
(new name:getNodesBounds
)project
(new name:screenToFlowPosition
)getMarkerEndId
Now that you successfully migrated to v12, you can use all the fancy features. As mentioned above, the biggest updates for v12 are:
- SSR / SSG: you can define
width
,height
andhandles
for the nodes. This makes it possible to render a flow on the server and hydrate on the client: codesandbox- Details: In v11,
width
andheight
were set by the library as soon as the nodes got measured. This still happens, but we are now usingcomputed.width
andcomputed.height
to store this information. ThepositionAbsolute
attribute also gets stored incomputed
. In the previous versions there was always a lot of confusion aboutwidth
andheight
. It’s hard to understand, that you can’t use it for passing an actual width or height. It’s also not obvious that those attributes get added by the library. We think that the new implementation solves both of the problems:width
andheight
are optional attributes that can be used to define dimensions and everything that is set by the library, is stored incomputed
.
- Details: In v11,
- Reactive Flows: The new hooks
useHandleConnections
anduseNodesData
and the newupdateNode
andupdateNodeData
functions can be used for managing the data flow between your nodes: codesandbox- Details: Working with reactive flows is super common. You update node A and want to react on those changes in the connected node B. Until now everyone had to come up with a custom solution. With this version we want to change this and give you performant helpers to handle this. If you are excited about this, you can check out this example:
- Dark mode and css variables: React Flow now comes with a built-in dark mode, that can be toggled by using the new
colorMode
prop (”light”, “dark” or “system”): codesandbox- Details: With this version we want to make it easier to switch between dark and light modes and give you a better starting point for dark flows. If you pass colorMode=”dark”, we add the class name “dark” to the wrapper and use it to adjust the styling. To make the implementation for this new feature easier on our ends, we switched to CSS variables for most of the styles. These variables can also be used in user land to customize a flow.
There is more! Besides the new main features, we added some minor things that were on our list for a long time. We also started to use TS docs for better docs. We already started to add some docs for some types and hooks which should improve the developer experience.
useConnection
hook: This hook makes it possible to handle an ongoing connection. For example, you can use it for colorizing handles.onDelete
handler: We added a combined handler foronDeleteNodes
andonDeleteEdges
to make it easier to react to deletions.isValidConnection
prop: This makes it possible to implement one validation function for all connections. It also gets called for programatically added edges.- Controlled
viewport
: This is definitely an advanced feature. Possible use cases are to animate the viewport or round the transform for lower res screens for example. This features brings two new props:viewport
andonViewportChange
. ViewportPortal
component: This makes it possible to render elements in the viewport without the need to implement a custom node.- Background component: add
patternClassName
to be able to style the background pattern by using a class name. This is useful if you want to style the background pattern with Tailwind for example. onMove
callback gets triggered for library-invoked viewport updates (like fitView or zoom-in)deleteElements
now returns deleted nodes and deleted edges- add
origin
attribute for nodes - add
selectable
attribute for edges - Correct types for
BezierEdge
,StepEdge
,SmoothStepEdge
andStraightEdge
components - New edges created by the library only have
sourceHandle
andtargetHandle
attributes when those attributes are set. (We used to passsourceHandle: null
andtargetHandle: null
) - Edges do not mount/unmount when their z-index change
These changes are not really user-facing, but it could be important for folks who are working with the React Flow store:
- The biggest internal change is that we created a new package @xyflow/system with framework agnostic helpers that can be used be React Flow and Svelte Flow
- XYDrag for handling dragging node(s) and selection
- XYPanZoom for controlling the viewport panning and zooming
- XYHandle for managing new connections
- We replaced the
nodeInternals
map with anodes
array. We added a newnodeLookup
map that serves as a lookup, but we are not creating a new map object on any change so it’s really only useful as a lookup. - We removed
connectionNodeId
,connectionHandleId
,connectionHandleType
from the store and addedconnectionStartHandle.nodeId
,connectionStartHandle.handleId
, … - add
data-id
to edges
With v12 the reactflow
package was renamed to @xyflow/react
- you can find the v11 source and the reactflow
changelog on the v11 branch.