Indexing into State var Strings Error
Alek99 opened this issue · comments
Alek Petuskey commented
Describe the bug
A clear and concise description of what the bug is.
where name is a var
def pypi_download_box(name: str, downloads: str) -> rx.Component:
return rx.hstack(
rx.heading(
name[6:],
size="2",
),
rx.box(
flex_grow=1,
),
rx.tooltip(
rx.badge(
downloads,
rx.icon(tag="external-link", size=12),
padding_x=".5em",
font_size="0.75em",
border_radius="6px",
justify="center",
align_items="center",
),
content="PyPI downloads last month",
),
width="100%",
justify_content="center",
)
Nikhil Rao commented
Is this within a foreach? A normal string indexing works for me:
"""Welcome to Reflex! This file create a counter app."""
import reflex as rx
class State(rx.State):
"""The app state."""
text = "Hello, Reflex!"
def index(downloads: str = 22) -> rx.Component:
return rx.hstack(
rx.heading(
State.text[8:],
size="2",
),
rx.box(
flex_grow=1,
),
rx.tooltip(
rx.badge(
downloads,
rx.icon(tag="external-link", size=12),
padding_x=".5em",
font_size="0.75em",
border_radius="6px",
justify="center",
align_items="center",
),
content="PyPI downloads last month",
),
width="100%",
justify_content="center",
)
app = rx.App()
app.add_page(index, title="Counter")
Alek Petuskey commented
yeah its in a foreach