From 6708e6e8c6998b7de9df6dd6ea9ff39cea44c7b4 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Fri, 19 May 2023 10:54:37 +0800 Subject: [PATCH] fix(merge): fix onChange props. (#502) --- merge/src/Internal.tsx | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/merge/src/Internal.tsx b/merge/src/Internal.tsx index 7bce755c3..81d5d8162 100644 --- a/merge/src/Internal.tsx +++ b/merge/src/Internal.tsx @@ -60,29 +60,20 @@ export const Internal = React.forwardRef((props: CodeMirrorMergeProps, ref?: Rea if (otherStore.collapseUnchanged !== collapseUnchanged) { opts.collapseUnchanged = collapseUnchanged; } - if (Object.keys(opts).length && dispatch && original && modified && editor.current) { + if (Object.keys(opts).length && dispatch) { + dispatch({ ...opts }); + } + if (original && modified && editor.current) { view.destroy(); - const viewDefault = new MergeView({ - a: original, - b: modified, + new MergeView({ + a: { ...original }, + b: { ...modified }, parent: editor.current, ...opts, }); - dispatch({ ...opts, renderRevertControl, view: viewDefault }); } } - }, [ - view, - original, - modified, - editor, - orientation, - revertControls, - highlightChanges, - gutter, - collapseUnchanged, - renderRevertControl, - ]); + }, [view, original, modified, editor, orientation, revertControls, highlightChanges, gutter, collapseUnchanged]); const defaultClassNames = 'cm-merge-theme'; return (