From 381cbe2db2831f6e7126ac0398cb69fd929712fa Mon Sep 17 00:00:00 2001 From: leileizhang Date: Mon, 30 Dec 2019 13:44:08 +0800 Subject: [PATCH] update local data when data change out the form (#1808) --- .../packages/extensions/obiformeditor/src/FormEditor.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Composer/packages/extensions/obiformeditor/src/FormEditor.tsx b/Composer/packages/extensions/obiformeditor/src/FormEditor.tsx index c198c6688d..450cf8764d 100644 --- a/Composer/packages/extensions/obiformeditor/src/FormEditor.tsx +++ b/Composer/packages/extensions/obiformeditor/src/FormEditor.tsx @@ -3,7 +3,7 @@ /** @jsx jsx */ import { Global, jsx } from '@emotion/core'; -import React, { useState, useMemo } from 'react'; +import React, { useState, useMemo, useEffect } from 'react'; import { Dropdown } from 'office-ui-fabric-react/lib/Dropdown'; import { JSONSchema6Definition, JSONSchema6 } from 'json-schema'; import merge from 'lodash/merge'; @@ -34,6 +34,12 @@ export const FormEditor: React.FunctionComponent = props => { const [localData, setLocalData] = useState(data); const type = getType(localData); + useEffect(() => { + if (!isEqual(localData, data)) { + setLocalData(data); + } + }, [data]); + const formErrors = useMemo(() => { if (props.currentDialog && props.currentDialog.diagnostics) { const currentPath = props.focusPath.replace('#', '');