From 6fa9bfea090f2c2a4a9f0653a2b8dbc81d1f6220 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Wed, 6 Sep 2023 14:02:24 -0700 Subject: [PATCH] Fix rx.Cookie with custom name (#1767) --- integration/test_client_storage.py | 3 +++ reflex/.templates/web/utils/state.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/integration/test_client_storage.py b/integration/test_client_storage.py index 5545d1e06..269725ed7 100644 --- a/integration/test_client_storage.py +++ b/integration/test_client_storage.py @@ -245,6 +245,9 @@ def test_client_side_state( input_value_input.send_keys("c5 value") set_sub_state_button.click() state_var_input.send_keys("c6") + input_value_input.send_keys("c6 throwaway value") + set_sub_state_button.click() + state_var_input.send_keys("c6") input_value_input.send_keys("c6 value") set_sub_state_button.click() state_var_input.send_keys("c7") diff --git a/reflex/.templates/web/utils/state.js b/reflex/.templates/web/utils/state.js index 9b90145a0..d45509146 100644 --- a/reflex/.templates/web/utils/state.js +++ b/reflex/.templates/web/utils/state.js @@ -413,7 +413,7 @@ const applyClientStorageDelta = (client_storage, delta) => { for (const key in delta[substate]) { const state_key = `${substate}.${key}` if (client_storage.cookies && state_key in client_storage.cookies) { - const cookie_options = client_storage.cookies[state_key] + const cookie_options = {...client_storage.cookies[state_key]} const cookie_name = cookie_options.name || state_key delete cookie_options.name // name is not a valid cookie option cookies.set(cookie_name, delta[substate][key], cookie_options);