Skip to content

Commit 553a885

Browse files
Revert "move state.js to jinja, related to reflex-dev#3738"
This reverts commit 4d2a72c.
1 parent 498f473 commit 553a885

File tree

5 files changed

+2
-45
lines changed

5 files changed

+2
-45
lines changed

reflex/.templates/jinja/web/utils/state.js.jinja2 reflex/.templates/web/utils/state.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ export const useEventLoop = (
809809
const vars = {};
810810
vars[storage_to_state_map[e.key]] = e.newValue;
811811
const event = Event(
812-
`${state_name}.{{ const.update_vars_internal }}`,
812+
`${state_name}.{{ update_vars_internal }}`,
813813
{ vars: vars }
814814
);
815815
addEvents([event], e);
@@ -823,7 +823,7 @@ export const useEventLoop = (
823823
// Route after the initial page hydration.
824824
useEffect(() => {
825825
const change_start = () => {
826-
const main_state_dispatch = dispatch["{{ const.state_name }}"];
826+
const main_state_dispatch = dispatch["state"];
827827
if (main_state_dispatch !== undefined) {
828828
main_state_dispatch({ is_hydrated: false });
829829
}

reflex/compiler/compiler.py

-21
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,6 @@ def _compile_contexts(state: Optional[Type[BaseState]], theme: Component | None)
126126
)
127127

128128

129-
def _compile_state() -> str:
130-
"""Compile the state.
131-
132-
Returns:
133-
The compiled state.
134-
"""
135-
return templates.state().render()
136-
137-
138129
def _compile_page(
139130
component: BaseComponent,
140131
state: Type[BaseState] | None,
@@ -433,18 +424,6 @@ def compile_contexts(
433424
return output_path, _compile_contexts(state, theme)
434425

435426

436-
def compile_state() -> tuple[str, str]:
437-
"""Compile the state.
438-
439-
Returns:
440-
The path and code of the compiled state.
441-
"""
442-
output_path = utils.get_state_path()
443-
444-
code = _compile_state()
445-
return output_path, code
446-
447-
448427
def compile_page(
449428
path: str, component: BaseComponent, state: Type[BaseState] | None
450429
) -> tuple[str, str]:

reflex/compiler/templates.py

-11
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def __init__(self) -> None:
1414
from reflex.state import (
1515
FrontendEventExceptionState,
1616
OnLoadInternalState,
17-
State,
1817
UpdateVarsInternalState,
1918
)
2019

@@ -49,7 +48,6 @@ def __init__(self) -> None:
4948
"set_color_mode": constants.ColorMode.SET,
5049
"use_color_mode": constants.ColorMode.USE,
5150
"hydrate": constants.CompileVars.HYDRATE,
52-
"state_name": State.get_name(),
5351
"on_load_internal": f"{OnLoadInternalState.get_name()}.on_load_internal",
5452
"update_vars_internal": f"{UpdateVarsInternalState.get_name()}.update_vars_internal",
5553
"frontend_exception_state": FrontendEventExceptionState.get_full_name(),
@@ -113,15 +111,6 @@ def context():
113111
return get_template("web/utils/context.js.jinja2")
114112

115113

116-
def state():
117-
"""Template for the state file.
118-
119-
Returns:
120-
Template: The template for the state file.
121-
"""
122-
return get_template("web/utils/state.js.jinja2")
123-
124-
125114
def tailwind_config():
126115
"""Template for Tailwind config.
127116

reflex/compiler/utils.py

-9
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,6 @@ def get_context_path() -> str:
399399
return str(get_web_dir() / (constants.Dirs.CONTEXTS_PATH + constants.Ext.JS))
400400

401401

402-
def get_state_path() -> str:
403-
"""Get the path of the state file.
404-
405-
Returns:
406-
The path of the state module.
407-
"""
408-
return str(get_web_dir() / (constants.Dirs.STATES_PATH + constants.Ext.JS))
409-
410-
411402
def get_components_path() -> str:
412403
"""Get the path of the compiled components.
413404

reflex/constants/base.py

-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class Dirs(SimpleNamespace):
3535
COMPONENTS_PATH = "/".join([UTILS, "components"])
3636
# The name of the contexts file.
3737
CONTEXTS_PATH = "/".join([UTILS, "context"])
38-
# The name of the states file.
39-
STATES_PATH = "/".join([UTILS, "state"])
4038
# The name of the output static directory.
4139
STATIC = "_static"
4240
# The name of the public html directory served at "/"

0 commit comments

Comments
 (0)