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

Prepend hydrate event when connecting #4929

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

masenf
Copy link
Collaborator

@masenf masenf commented Mar 8, 2025

Avoid backend on_mount events triggering a reload message, which ends up requeuing hydrate event.

import reflex as rx


class State(rx.State):
    def fooooooo(self):
        print("Foooo!")

    def on_load(self):
        print("on_load scrode")


def index() -> rx.Component:
    return rx.box("Hola Mundo", on_mount=[State.fooooooo, State.fooooooo, State.fooooooo])


app = rx.App()
app.add_page(index, on_load=State.on_load)

Before the fix, this code triggers on_load four times 🫨

Avoid backend on_mount events triggering a `reload` message, which ends up
requeuing hydrate event.
Copy link

codspeed-hq bot commented Mar 8, 2025

CodSpeed Performance Report

Merging #4929 will not alter performance

Comparing masenf/fix-reload-on-mount (0c63a86) with main (5c8104f)

Summary

✅ 12 untouched benchmarks

@benedikt-bartscher
Copy link
Contributor

Before the fix, this code triggers on_load four times 🫨

...and after it only once, awesome!

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.

2 participants