Skip to content

Commit

Permalink
Fix props
Browse files Browse the repository at this point in the history
  • Loading branch information
OhKai committed Jan 7, 2024
1 parent 0e9d308 commit 2640f4c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/management-system-v2/components/bpmn-viewer.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use client';

import React, { useEffect, useRef } from 'react';
import React, { useEffect, useMemo, useRef } from 'react';
import cn from 'classnames';
import BPMNCanvas from './bpmn-canvas';
import BPMNCanvas, { BPMNCanvasRef } from './bpmn-canvas';
import { getProcessBPMN } from '@/lib/data/processes';
import { useSuspenseQuery } from '@tanstack/react-query';

Expand All @@ -13,7 +13,7 @@ type BPMNViewerProps = {
};

const BPMNViewer = ({ definitionId, reduceLogo, fitOnResize }: BPMNViewerProps) => {
const viewer = useRef();
const viewer = useRef<BPMNCanvasRef | null>(null);

const { data } = useSuspenseQuery({
queryKey: ['process', definitionId, 'bpmn'],
Expand All @@ -32,6 +32,9 @@ const BPMNViewer = ({ definitionId, reduceLogo, fitOnResize }: BPMNViewerProps)
},
});

// Allows for rerendering when the process changes but not the BPMN.
const bpmn = useMemo(() => ({ bpmn: data }), [data]);

useEffect(() => {
console.log('viewer', viewer.current);
//viewer.current!.fitViewport();
Expand All @@ -40,7 +43,7 @@ const BPMNViewer = ({ definitionId, reduceLogo, fitOnResize }: BPMNViewerProps)
return (
<BPMNCanvas
ref={viewer}
bpmn={data}
bpmn={bpmn}
type="viewer"
className={cn({ reduceLogo: reduceLogo })}
resizeWithContainer={fitOnResize}
Expand Down

0 comments on commit 2640f4c

Please sign in to comment.