Fix mutated closedCurtains state in curtains.
This commit is contained in:
parent
f3c8a9858b
commit
ed4e766650
1 changed files with 3 additions and 2 deletions
|
@ -135,12 +135,13 @@ export function Curtains({children}: React.PropsWithChildren<{}>)
|
||||||
remove.current = useCallback((uuid: CurtainUuidType) => {
|
remove.current = useCallback((uuid: CurtainUuidType) => {
|
||||||
// Copy the curtains list.
|
// Copy the curtains list.
|
||||||
const newCurtains = {...curtains};
|
const newCurtains = {...curtains};
|
||||||
|
const newClosedCurtains = {...closedCurtains};
|
||||||
// Remove the given curtain from the list.
|
// Remove the given curtain from the list.
|
||||||
delete newCurtains[uuid];
|
delete newCurtains[uuid];
|
||||||
delete closedCurtains[uuid];
|
delete newClosedCurtains[uuid];
|
||||||
// Set the new curtains list.
|
// Set the new curtains list.
|
||||||
setCurtains(newCurtains);
|
setCurtains(newCurtains);
|
||||||
setClosedCurtains(closedCurtains);
|
setClosedCurtains(newClosedCurtains);
|
||||||
}, [curtains, setCurtains, closedCurtains, setClosedCurtains]);
|
}, [curtains, setCurtains, closedCurtains, setClosedCurtains]);
|
||||||
|
|
||||||
// Initialize close curtain function with animation.
|
// Initialize close curtain function with animation.
|
||||||
|
|
Loading…
Reference in a new issue