From 2062c1dd056de65d1ecf5280ad8eb33cdfb2f764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Brand=C3=A9ho?= Date: Wed, 28 Feb 2024 03:31:38 +0100 Subject: [PATCH] fix initial value for color_mode (#2741) * fix initial value for color_mode * better fix --- reflex/compiler/compiler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/reflex/compiler/compiler.py b/reflex/compiler/compiler.py index b65666848..6256b7ab1 100644 --- a/reflex/compiler/compiler.py +++ b/reflex/compiler/compiler.py @@ -1,4 +1,5 @@ """Compiler for the reflex apps.""" + from __future__ import annotations import os @@ -78,18 +79,21 @@ def _compile_contexts(state: Optional[Type[BaseState]], theme: Component) -> str Returns: The compiled context file. """ + appearance = getattr(theme, "appearance", None) + if appearance is None: + appearance = LIGHT_COLOR_MODE return ( templates.CONTEXT.render( initial_state=utils.compile_state(state), state_name=state.get_name(), client_storage=utils.compile_client_storage(state), is_dev_mode=_is_dev_mode(), - default_color_mode=getattr(theme, "appearance", LIGHT_COLOR_MODE), + default_color_mode=appearance, ) if state else templates.CONTEXT.render( is_dev_mode=_is_dev_mode(), - default_color_mode=getattr(theme, "appearance", LIGHT_COLOR_MODE), + default_color_mode=appearance, ) )