Skip to content

Commit 80ca1ac

Browse files
committed
type component
1 parent db92c2b commit 80ca1ac

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

reflex/components/component.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import reflex.state
2424
from reflex import constants
25-
from reflex import constants
2625
from reflex.compiler.templates import stateful_component_template
2726
from reflex.components.core.breakpoints import Breakpoints
2827
from reflex.components.dynamic import load_dynamic_serializer
@@ -2243,24 +2242,23 @@ def wrapper(*children, **props) -> CustomComponent:
22432242

22442243
# Register this component so it can be compiled.
22452244
dummy_component = _register_custom_component(component_fn)
2246-
object.__setattr__(
2247-
wrapper,
2248-
"_as_var",
2249-
lambda: Var(
2250-
f"jsx({dummy_component.tag})",
2251-
_var_type=Component,
2252-
_var_data=VarData(
2253-
imports={
2254-
f"$/{constants.Dirs.UTILS}/components": [
2255-
ImportVar(tag=dummy_component.tag)
2256-
],
2257-
"@emotion/react": [
2258-
ImportVar(tag="jsx"),
2259-
],
2260-
}
2245+
if tag := dummy_component.tag:
2246+
object.__setattr__(
2247+
wrapper,
2248+
"_as_var",
2249+
lambda: Var(
2250+
tag,
2251+
_var_type=type[Component],
2252+
_var_data=VarData(
2253+
imports={
2254+
f"$/{constants.Dirs.UTILS}/components": [ImportVar(tag=tag)],
2255+
"@emotion/react": [
2256+
ImportVar(tag="jsx"),
2257+
],
2258+
}
2259+
),
22612260
),
2262-
),
2263-
)
2261+
)
22642262

22652263
return wrapper
22662264

0 commit comments

Comments
 (0)