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

Merged
merged 4 commits into from
Mar 14, 2025
Merged

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!

@adhami3310 adhami3310 merged commit debc5bb into main Mar 14, 2025
43 checks passed
@adhami3310 adhami3310 deleted the masenf/fix-reload-on-mount branch March 14, 2025 17:38
bhatia2akshit pushed a commit to bhatia2akshit/reflex that referenced this pull request Mar 15, 2025
* Prepend hydrate event when connecting

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

* Use .shift instead of .pop

* processEvent takes care of socket not being connected
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.

None yet

3 participants