Fix all typescript type issues
parent
f06509e904
commit
8d70c86460
18
src/App.tsx
18
src/App.tsx
|
@ -5,14 +5,19 @@ import ReactFlow, {
|
||||||
applyEdgeChanges,
|
applyEdgeChanges,
|
||||||
applyNodeChanges,
|
applyNodeChanges,
|
||||||
addEdge,
|
addEdge,
|
||||||
|
Node,
|
||||||
|
Edge,
|
||||||
|
NodeChange,
|
||||||
|
EdgeChange,
|
||||||
|
Connection,
|
||||||
} from 'reactflow';
|
} from 'reactflow';
|
||||||
|
|
||||||
// we have to import the React Flow styles for it to work
|
// we have to import the React Flow styles for it to work
|
||||||
import 'reactflow/dist/style.css';
|
import 'reactflow/dist/style.css';
|
||||||
|
|
||||||
const initialEdges = [];
|
const initialEdges: Edge[] = [];
|
||||||
|
|
||||||
const initialNodes = [
|
const initialNodes: Node[] = [
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
data: { label: 'Hello' },
|
data: { label: 'Hello' },
|
||||||
|
@ -31,16 +36,19 @@ const Flow = () => {
|
||||||
const [edges, setEdges] = useState(initialEdges);
|
const [edges, setEdges] = useState(initialEdges);
|
||||||
|
|
||||||
const onNodesChange = useCallback(
|
const onNodesChange = useCallback(
|
||||||
changes => setNodes(nds => applyNodeChanges(changes, nds)),
|
(changes: NodeChange[]) =>
|
||||||
|
setNodes((nds: Node[]) => applyNodeChanges(changes, nds)),
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
const onEdgesChange = useCallback(
|
const onEdgesChange = useCallback(
|
||||||
changes => setEdges(eds => applyEdgeChanges(changes, eds)),
|
(changes: EdgeChange[]) =>
|
||||||
|
setEdges((eds: Edge[]) => applyEdgeChanges(changes, eds)),
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
const onConnect = useCallback(
|
const onConnect = useCallback(
|
||||||
params => setEdges(eds => addEdge(params, eds)),
|
(params: Edge | Connection) =>
|
||||||
|
setEdges((eds: Edge[]) => addEdge(params, eds)),
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue