reflex-dev / reflex

🕸️ Web apps in pure Python 🐍

Home Page:https://reflex.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Indexing into State var Strings Error

Alek99 opened this issue · comments

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",
    )

produces
Screenshot 2024-04-18 at 3 59 20 PM

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")

yeah its in a foreach