开源白板工具(SaaS),一体化白板,包含思维导图、流程图、自由画等。All in one open-source whiteboard tool with mind, flowchart, freehand and etc.
feat(component): support update value from drawnix component outside (#103)
pubuzhixing8d72eaf4604f5
diff --git a/packages/react-board/src/wrapper.tsx b/packages/react-board/src/wrapper.tsxindex 5f9297b..adf4a95 100644--- a/packages/react-board/src/wrapper.tsx+++ b/packages/react-board/src/wrapper.tsx@@ -27,9 +27,10 @@ import {initializeViewBox,withI18n,updateViewBox,+ FLUSHING,} from '@plait/core';import { BoardChangeData } from './plugins/board';-import { useCallback, useEffect, useState } from 'react';+import { useCallback, useEffect, useRef, useState } from 'react';import { withReact } from './plugins/with-react';import { PlaitCommonElementRef, withImage, withText } from '@plait/common';import { BoardContext, BoardContextValue } from './hooks/use-board';@@ -182,6 +183,24 @@ export const Wrapper: React.FC<WrapperProps> = ({};}, [board]);+ const isFirstRender = useRef(true);++ useEffect(() => {+ if (isFirstRender.current) {+ isFirstRender.current = false;+ return;+ }++ if (value !== context.board.children && !FLUSHING.get(board)) {+ board.children = value;+ listRender.update(board.children, {+ board: board,+ parent: board,+ parentG: PlaitBoard.getElementHost(board),+ });+ }+ }, [value]);+return (<BoardContext.Provider value={context}>{children}</BoardContext.Provider>);