diff --git a/core/src/editor/objectKey.tsx b/core/src/editor/objectKey.tsx index efc89679..d4fd7bc8 100644 --- a/core/src/editor/objectKey.tsx +++ b/core/src/editor/objectKey.tsx @@ -12,6 +12,7 @@ export const ObjectKey: FC>= (props) => { const { className, value, keyName, parentName, quotes, label, onEdit, highlightUpdates = true, render, ...reset } = props; const [editable, setEditable] = useState(false); const [curentLabel, setCurentLabel] = useState(label); + useEffect(() => setCurentLabel(label), [label]); const $edit = useRef(null); useHighlight({ value, highlightUpdates: highlightUpdates, highlightContainer: $edit }); const click = (evn: React.MouseEvent) => { diff --git a/core/src/editor/value.tsx b/core/src/editor/value.tsx index fef02cc8..d6a41df1 100644 --- a/core/src/editor/value.tsx +++ b/core/src/editor/value.tsx @@ -1,4 +1,4 @@ -import { FC, Fragment, PropsWithChildren, useRef, useState } from 'react'; +import { FC, Fragment, PropsWithChildren, useEffect, useRef, useState } from 'react'; import type { TypeProps } from '../value'; import { getValueString, isFloat, Type, typeMap } from '../value'; import { EditIcon } from './icon/edit'; @@ -25,6 +25,7 @@ export function ReValue(props: ReValueProps) { const $edit = useRef(null); const [curentType, setCurentType] = useState(type); const [curentChild, setCurentChild] = useState(value); + useEffect(() => setCurentChild(value), [value]); const click = (evn: React.MouseEvent) => { evn.stopPropagation(); if ($edit.current) {