Skip to content

Commit

Permalink
update local data when data change out the form (microsoft#1808)
Browse files Browse the repository at this point in the history
  • Loading branch information
lei9444 authored and boydc2014 committed Dec 30, 2019
1 parent 5530d20 commit 381cbe2
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -34,6 +34,12 @@ export const FormEditor: React.FunctionComponent<FormEditorProps> = 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('#', '');
Expand Down

0 comments on commit 381cbe2

Please sign in to comment.