From 1553751287e4461ab385357756e8f7a1e040e6c9 Mon Sep 17 00:00:00 2001 From: Elvy <88881326+EepyElvyra@users.noreply.github.com> Date: Sat, 4 Jan 2025 18:31:15 +0100 Subject: [PATCH] ensure value gets updated correctly --- .../components/SettingArrayComponent.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/PluginSettings/components/SettingArrayComponent.tsx b/src/components/PluginSettings/components/SettingArrayComponent.tsx index ff2c1f6c6..002ee1b94 100644 --- a/src/components/PluginSettings/components/SettingArrayComponent.tsx +++ b/src/components/PluginSettings/components/SettingArrayComponent.tsx @@ -89,8 +89,9 @@ export function SettingArrayComponent({ pluginSettings[id] = []; return; } - setItems(items.filter((_, i) => i !== index)); - pluginSettings[id] = items; + const newItems = items.filter((_, i) => i !== index); + setItems(newItems); + pluginSettings[id] = newItems; }; function renderGuildView() { @@ -253,9 +254,11 @@ export function SettingArrayComponent({ return; } - setItems([...items, inputElement.value]); + const newItems = [...items, inputElement.value]; - pluginSettings[id] = items; + setItems(newItems); + + pluginSettings[id] = newItems; inputElement.value = ""; }