Skip to content

Commit ebff191

Browse files
committed
fix: fix update value issue.
1 parent afd0f60 commit ebff191

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

core/src/editor/objectKey.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const ObjectKey: FC<ObjectKeyProps<object>>= (props) => {
1212
const { className, value, keyName, parentName, quotes, label, onEdit, highlightUpdates = true, render, ...reset } = props;
1313
const [editable, setEditable] = useState(false);
1414
const [curentLabel, setCurentLabel] = useState(label);
15+
useEffect(() => setCurentLabel(label), [label]);
1516
const $edit = useRef<HTMLSpanElement>(null);
1617
useHighlight({ value, highlightUpdates: highlightUpdates, highlightContainer: $edit });
1718
const click = (evn: React.MouseEvent<HTMLSpanElement, MouseEvent>) => {

core/src/editor/value.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, Fragment, PropsWithChildren, useRef, useState } from 'react';
1+
import { FC, Fragment, PropsWithChildren, useEffect, useRef, useState } from 'react';
22
import type { TypeProps } from '../value';
33
import { getValueString, isFloat, Type, typeMap } from '../value';
44
import { EditIcon } from './icon/edit';
@@ -25,6 +25,7 @@ export function ReValue<T extends object>(props: ReValueProps<T>) {
2525
const $edit = useRef<HTMLSpanElement>(null);
2626
const [curentType, setCurentType] = useState(type);
2727
const [curentChild, setCurentChild] = useState(value);
28+
useEffect(() => setCurentChild(value), [value]);
2829
const click = (evn: React.MouseEvent<SVGElement, MouseEvent>) => {
2930
evn.stopPropagation();
3031
if ($edit.current) {

0 commit comments

Comments
 (0)