Skip to content

Conversation

@adhami3310
Copy link
Member

import reflex as rx


class State(rx.State):
    """A simple state that stores the score."""

    score: int = 0

    @rx.event
    def increment(self):
        """Increment the score by 10."""
        self.score += 10


@rx.page("/")
@rx.dynamic
def index(state: State):
    """A simple counter that increments the score when clicked."""
    return rx.vstack(
        rx.text(
            f"Score: {state.score}",
            " which is a high score!" if state.score > 100 else "",
        ),
        rx.button("Increment", on_click=State.increment),
    )


app = rx.App()

@adhami3310 adhami3310 marked this pull request as ready for review October 17, 2024 21:50
Lendemor
Lendemor previously approved these changes Oct 18, 2024
@adhami3310 adhami3310 merged commit 3eab2b6 into main Oct 22, 2024
Kastier1 pushed a commit that referenced this pull request Oct 23, 2024
* implement rx dynamic

* dang it darglint

* add custom type
@masenf masenf deleted the implement-rx-dynamic branch December 12, 2024 07:03
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.

4 participants