Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement rx dynamic #4195

Merged
merged 4 commits into from
Oct 22, 2024
Merged

implement rx dynamic #4195

merged 4 commits into from
Oct 22, 2024

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
reflex/state.py Outdated Show resolved Hide resolved
Lendemor
Lendemor previously approved these changes Oct 18, 2024
@adhami3310 adhami3310 merged commit 3eab2b6 into main Oct 22, 2024
31 checks passed
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.

3 participants