From ed4e766650d7ae6c1dde03ed8cef8f8fb014ef69 Mon Sep 17 00:00:00 2001 From: Madeorsk Date: Sun, 14 Jul 2024 19:20:11 +0200 Subject: [PATCH] Fix mutated closedCurtains state in curtains. --- src/Components/Curtains/Curtains.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Components/Curtains/Curtains.tsx b/src/Components/Curtains/Curtains.tsx index ffa5b45..6470190 100644 --- a/src/Components/Curtains/Curtains.tsx +++ b/src/Components/Curtains/Curtains.tsx @@ -135,12 +135,13 @@ export function Curtains({children}: React.PropsWithChildren<{}>) remove.current = useCallback((uuid: CurtainUuidType) => { // Copy the curtains list. const newCurtains = {...curtains}; + const newClosedCurtains = {...closedCurtains}; // Remove the given curtain from the list. delete newCurtains[uuid]; - delete closedCurtains[uuid]; + delete newClosedCurtains[uuid]; // Set the new curtains list. setCurtains(newCurtains); - setClosedCurtains(closedCurtains); + setClosedCurtains(newClosedCurtains); }, [curtains, setCurtains, closedCurtains, setClosedCurtains]); // Initialize close curtain function with animation.