Skip to content

Commit

Permalink
Demonstrate ReactFlow 11.11.0 bug
Browse files Browse the repository at this point in the history
Signed-off-by: Drew Hess <[email protected]>
  • Loading branch information
dhess committed Apr 10, 2024
1 parent a76dc84 commit 5ea182d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"react-dom": "^18.2.0",
"react-hook-form": "^7.51.2",
"react-router-dom": "^6.22.3",
"reactflow": "^11.10.3",
"reactflow": "^11.11.0",
"universal-cookie": "^7.1.4",
"uuid": "^9.0.1",
"zod": "^3.22.4"
Expand Down
54 changes: 27 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions src/components/EvalFull/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from "react";
import { NodeChange, ReactFlowProvider, useReactFlow } from "reactflow";
import { useState, useCallback } from "react";
import { Node, NodeChange, ReactFlowProvider, useReactFlow, applyNodeChanges } from "reactflow";
import { EvalFullResp, GlobalName, Level } from "@/primer-api";
import { SelectMenu, TreeReactFlowOne } from "@/components";
import {
Expand Down Expand Up @@ -27,9 +27,14 @@ const Evaluated = (p: {
}) => {
const padding = 1.0;
const { fitView } = useReactFlow();
const onNodesChange = (_: NodeChange[]) => {
fitView({ padding });
};
const [_, setNodes] = useState<Node[]>([]);

Check warning on line 30 in src/components/EvalFull/index.tsx

View workflow job for this annotation

GitHub Actions / deploy-to-chromatic

'_' is assigned a value but never used
const onNodesChange = useCallback(
(changes: NodeChange[]) => {
setNodes((oldNodes: Node[]) => applyNodeChanges(changes, oldNodes));
fitView({ padding });
},
[setNodes, fitView]
);

return (
<TreeReactFlowOne
Expand Down
14 changes: 10 additions & 4 deletions src/components/SelectionInfo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NodeChange, ReactFlowProvider, useReactFlow } from "reactflow";
import { useState, useCallback } from "react";
import { Node, NodeChange, ReactFlowProvider, useReactFlow, applyNodeChanges } from "reactflow";
import { Tree, Level, TypeOrKind } from "@/primer-api";
import { TreeReactFlowOne } from "@/components";
import {
Expand All @@ -19,9 +20,14 @@ const TypeOrKindTree = (p: {
}) => {
const padding = 1.0;
const { fitView } = useReactFlow();
const onNodesChange = (_: NodeChange[]) => {
fitView({ padding });
};
const [_, setNodes] = useState<Node[]>([]);

Check warning on line 23 in src/components/SelectionInfo/index.tsx

View workflow job for this annotation

GitHub Actions / deploy-to-chromatic

'_' is assigned a value but never used
const onNodesChange = useCallback(
(changes: NodeChange[]) => {
setNodes((oldNodes: Node[]) => applyNodeChanges(changes, oldNodes));
fitView({ padding });
},
[setNodes, fitView]
);

return (
<TreeReactFlowOne
Expand Down

0 comments on commit 5ea182d

Please sign in to comment.