Skip to content

Commit 6afcaf6

Browse files
authored
reload config on __post_init__ (#5064)
* reload config on __call__ * maybe * move get config after app
1 parent f1bc532 commit 6afcaf6

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

reflex/app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ def __post_init__(self):
443443
"rx.BaseState cannot be subclassed directly. Use rx.State instead"
444444
)
445445

446+
get_config(reload=True)
447+
446448
if "breakpoints" in self.style:
447449
set_breakpoints(self.style.pop("breakpoints"))
448450

reflex/utils/codespaces.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,17 @@
1111
from reflex.components.core.banner import has_connection_errors
1212
from reflex.components.core.cond import cond
1313
from reflex.constants import Endpoint
14+
from reflex.utils.decorator import once
1415

15-
redirect_script = """
16+
17+
@once
18+
def redirect_script() -> str:
19+
"""Get the redirect script for Github Codespaces.
20+
21+
Returns:
22+
The redirect script as a string.
23+
"""
24+
return """
1625
const thisUrl = new URL(window.location.href);
1726
const params = new URLSearchParams(thisUrl.search)
1827
@@ -61,7 +70,7 @@ def codespaces_auto_redirect() -> list[Component]:
6170
A list containing the conditional redirect component, or empty list.
6271
"""
6372
if is_running_in_codespaces():
64-
return [cond(has_connection_errors, Script.create(redirect_script))]
73+
return [cond(has_connection_errors, Script.create(redirect_script()))]
6574
return []
6675

6776

@@ -87,5 +96,5 @@ async def auth_codespace() -> HTMLResponse:
8796
</body>
8897
</html>
8998
"""
90-
% redirect_script
99+
% redirect_script()
91100
)

tests/integration/test_extra_overlay_function.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
def ExtraOverlay():
1212
import reflex as rx
1313

14-
rx.config.get_config().extra_overlay_function = "reflex.components.moment.moment"
15-
1614
def index():
1715
return rx.vstack(
1816
rx.el.input(
@@ -26,6 +24,7 @@ def index():
2624
)
2725

2826
app = rx.App()
27+
rx.config.get_config().extra_overlay_function = "reflex.components.moment.moment"
2928
app.add_page(index)
3029

3130

0 commit comments

Comments
 (0)