Skip to content

Commit 454cc14

Browse files
committed
dynamic was the weird guy
1 parent 9ca5518 commit 454cc14

3 files changed

Lines changed: 7 additions & 17 deletions

File tree

reflex/compiler/compiler.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,8 @@
3333
def _apply_common_imports(
3434
imports: dict[str, list[ImportVar]],
3535
):
36-
if "@emotion/react" in imports:
37-
imports["@emotion/react"].append(ImportVar("jsx"))
38-
else:
39-
imports["@emotion/react"] = [ImportVar("jsx")]
40-
if "react" in imports:
41-
imports["react"].append(ImportVar("Fragment"))
42-
else:
43-
imports["react"] = [ImportVar("Fragment")]
36+
imports.setdefault("@emotion/react", []).append(ImportVar("jsx"))
37+
imports.setdefault("react", []).append(ImportVar("Fragment"))
4438

4539

4640
def _compile_document_root(root: Component) -> str:

reflex/components/component.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,13 +2642,6 @@ def _cached_get_all_var_data(self) -> VarData | None:
26422642
"""
26432643
return VarData.merge(
26442644
self._var_data,
2645-
VarData(
2646-
imports={
2647-
"@emotion/react": [
2648-
ImportVar(tag="jsx"),
2649-
],
2650-
}
2651-
),
26522645
VarData(
26532646
imports=self._var_value._get_all_imports(),
26542647
),

reflex/components/dynamic.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def make_component(component: Component) -> str:
7272
The generated code
7373
"""
7474
# Causes a circular import, so we import here.
75-
from reflex.compiler import templates, utils
75+
from reflex.compiler import compiler, templates, utils
7676
from reflex.components.base.bare import Bare
7777

7878
component = Bare.create(Var.create(component))
@@ -97,8 +97,11 @@ def make_component(component: Component) -> str:
9797

9898
libs_in_window = bundled_libraries
9999

100+
imports = component._get_all_imports()
101+
compiler._apply_common_imports(imports)
102+
100103
imports = {}
101-
for lib, names in component._get_all_imports().items():
104+
for lib, names in imports.items():
102105
formatted_lib_name = format_library_name(lib)
103106
if (
104107
not lib.startswith((".", "/", "$/"))

0 commit comments

Comments
 (0)