Skip to content

Commit

Permalink
fix(useMikadoGraph): display new nodes after adding a prerequisite
Browse files Browse the repository at this point in the history
  • Loading branch information
arnolanglade committed Oct 31, 2023
1 parent 8b0539d commit 8a5d677
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/mikado-graph/component/mikado-graph.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React from 'react';
import React, { useEffect, useState } from 'react';
import { StatusView } from '@/api/mikado-graph/mikado-graph';
import AddPrerequisiteForm from '@/mikado-graph/component/add-prerequisite-form';
import { Translation } from '@/tools/i18n/intl-provider';
Expand Down Expand Up @@ -126,8 +126,13 @@ export default function Graph({
}: {
mikadoGraph: MikadoGraph,
}) {
const [nodes, , onNodesChange] = useNodesState(mikadoGraph.nodes);
const [edges, , onEdgesChange] = useEdgesState(mikadoGraph.edges);
const [nodes, setNodes, onNodesChange] = useNodesState(mikadoGraph.nodes);
const [edges, setEdges, onEdgesChange] = useEdgesState(mikadoGraph.edges);

useEffect(() => {
setEdges(mikadoGraph.edges);
setNodes(mikadoGraph.nodes);
}, [mikadoGraph]);

return (
<ReactFlow
Expand Down

0 comments on commit 8a5d677

Please sign in to comment.