Skip to content

fix recursive UI - #4599

Merged
masenf merged 4 commits into
mainfrom
fix-recursive-UI
Jan 7, 2025
Merged

masenf merged 4 commits into
mainfrom
fix-recursive-UI

Conversation

@adhami3310

@adhami3310 adhami3310 commented Jan 7, 2025 •

Copy link
Copy Markdown
Member

this is now possible

@dataclass
class File:
    name: str
    children: list["File"]


@rx.memo
def folder(file: rx.Var[File]) -> rx.Component:
    return rx.vstack(
        rx.heading(file.name),
        rx.box(
            rx.foreach(file.children, lambda f: folder(file=f)),
            padding_inline_start="1em",
        ),
    )


def index() -> rx.Component:
    return folder(
        file=File(
            "home",
            [
                File(
                    "documents",
                    [],
                ),
                File(
                    "downloads",
                    [
                        File("images", []),
                        File("videos", []),
                        File("music", []),
                    ],
                ),
                File("pictures", []),
            ],
        )
    )

@masenf
masenf merged commit 0ad0a84 into main Jan 7, 2025
@masenf
masenf deleted the fix-recursive-UI branch January 7, 2025 23:11
@guidocalvano

Copy link
Copy Markdown

@guidocalvano

Copy link
Copy Markdown

Also, really cool that you fixed this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot render states with typing.ForwardRef Can Reflex deal with some state/components running in subprocesses? Recursive accordion fails

3 participants