refactored react-examples app and created generic test case component

This commit is contained in:
Peter
2023-11-07 16:19:09 +01:00
parent b8a75ccac6
commit 8be0337e00
7 changed files with 299 additions and 70 deletions
+29
View File
@@ -0,0 +1,29 @@
import { useState, useCallback } from 'react';
import { ReactFlow, Controls, Background, applyNodeChanges, applyEdgeChanges } from '@xyflow/react';
type FlowProps = {
generics: GenericTestCase;
};
export default ({ generics }: FlowProps) => {
const [nodes, setNodes] = useState(generics.reactFlowProps.nodes);
const [edges, setEdges] = useState(generics.reactFlowProps.edges);
const onNodesChange = useCallback((changes) => setNodes((nds) => applyNodeChanges(changes, nds)), []);
const onEdgesChange = useCallback((changes) => setEdges((eds) => applyEdgeChanges(changes, eds)), []);
return (
<div style={{ height: '100%' }}>
<ReactFlow
{...generics.reactFlowProps}
nodes={nodes}
onNodesChange={onNodesChange}
edges={edges}
onEdgesChange={onEdgesChange}
>
<Background />
<Controls />
</ReactFlow>
</div>
);
};