Skip to content

Commit

Permalink
fix: fix update value issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 26, 2023
1 parent afd0f60 commit ebff191
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/src/editor/objectKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const ObjectKey: FC<ObjectKeyProps<object>>= (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<HTMLSpanElement>(null);
useHighlight({ value, highlightUpdates: highlightUpdates, highlightContainer: $edit });
const click = (evn: React.MouseEvent<HTMLSpanElement, MouseEvent>) => {
Expand Down
3 changes: 2 additions & 1 deletion core/src/editor/value.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -25,6 +25,7 @@ export function ReValue<T extends object>(props: ReValueProps<T>) {
const $edit = useRef<HTMLSpanElement>(null);
const [curentType, setCurentType] = useState(type);
const [curentChild, setCurentChild] = useState(value);
useEffect(() => setCurentChild(value), [value]);
const click = (evn: React.MouseEvent<SVGElement, MouseEvent>) => {
evn.stopPropagation();
if ($edit.current) {
Expand Down

0 comments on commit ebff191

Please sign in to comment.