Skip to content

Commit 519ef1b

Browse files
committed
fix(samples): update TemplateMark, Concerto Model, and Preview Data on selection (accordproject#318)
Signed-off-by: surya4419 <suryaa4419@gmail.com>
1 parent 5e17e49 commit 519ef1b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/components/useUndoRedo.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import { useState } from 'react';
1+
import { useState,useEffect } from 'react';
22
function useUndoRedo<T>(initialValue: T, onChange?: (value: T) => void) {
33
const [past, setPast] = useState<T[]>([]);
44
const [present, setPresent] = useState<T>(initialValue);
55
const [future, setFuture] = useState<T[]>([]);
66

7+
useEffect(() => {
8+
setPresent(initialValue);
9+
setPast([]);
10+
setFuture([]);
11+
}, [initialValue]);
12+
713
const setValue = (newValue: T) => {
814
setPast((prevPast) => [...prevPast, present]);
915
setPresent(newValue);

0 commit comments

Comments
 (0)