Fix foreach index type (#1389)
This commit is contained in:
parent
915685c073
commit
723105d8bb
@ -5,7 +5,7 @@ import inspect
|
|||||||
from typing import TYPE_CHECKING, Callable, List
|
from typing import TYPE_CHECKING, Callable, List
|
||||||
|
|
||||||
from reflex.components.tags.tag import Tag
|
from reflex.components.tags.tag import Tag
|
||||||
from reflex.vars import Var
|
from reflex.vars import BaseVar, Var
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from reflex.components.component import Component
|
from reflex.components.component import Component
|
||||||
@ -30,9 +30,11 @@ class IterTag(Tag):
|
|||||||
Returns:
|
Returns:
|
||||||
The index var.
|
The index var.
|
||||||
"""
|
"""
|
||||||
index = Var.create(INDEX_VAR, is_local=False)
|
return BaseVar(
|
||||||
assert index is not None
|
name=INDEX_VAR,
|
||||||
return index
|
type_=int,
|
||||||
|
is_local=True,
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_index_var_arg() -> Var:
|
def get_index_var_arg() -> Var:
|
||||||
@ -41,9 +43,10 @@ class IterTag(Tag):
|
|||||||
Returns:
|
Returns:
|
||||||
The index var.
|
The index var.
|
||||||
"""
|
"""
|
||||||
arg = Var.create(INDEX_VAR)
|
return BaseVar(
|
||||||
assert arg is not None
|
name=INDEX_VAR,
|
||||||
return arg
|
type_=int,
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def render_component(render_fn: Callable, arg: Var) -> Component:
|
def render_component(render_fn: Callable, arg: Var) -> Component:
|
||||||
|
Loading…
Reference in New Issue
Block a user