Skip to content

Commit 77ebe5a

Browse files
fix: effect editor hold problem
1 parent ee29730 commit 77ebe5a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/origine2/src/hooks/useValue.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ const holdMap = new Map();
44

55
export function useValue<T>(initialState: T, isHold?: boolean, key?: string) {
66
const holdKey = key ?? '__value_hold_key__';
7-
const fromHoldValue = holdMap.get(holdKey);
7+
let fromHoldValue;
8+
if(isHold)
9+
fromHoldValue = holdMap.get(holdKey);
810
const [value, setValue] = useState<T>(fromHoldValue ?? initialState);
911
return {
1012
_value: value,

packages/origine2/src/pages/editor/GraphicalEditor/components/EffectEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export function EffectEditor(props: { json: string; onChange: (newJson: string)
273273
return effectFields as EffectFields;
274274
}, []);
275275
// 状态:存储所有效果参数的当前值(键为EffectKey,值为数值或undefined)
276-
const effectFields = useValue<EffectFields>(getInitialFields(props.json), true);
276+
const effectFields = useValue<EffectFields>(getInitialFields(props.json), true, "__effect_current");
277277
// 当父组件传递的 json 变化时,重新初始化状态
278278
useEffect(() => {
279279
effectFields.value = getInitialFields(props.json);

0 commit comments

Comments
 (0)