always send on load even on going on the link#5469
Merged
adhami3310 merged 6 commits intoJun 25, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
PR Summary
Modified state management to ensure on_load events are consistently triggered when navigating between pages, including navigation to the same page, fixing a regression introduced after moving away from NextJS.
- Modified
reflex/.templates/web/utils/state.jsto remove pathname/search/hash comparison checks, ensuring route change events fire on every location change - Added integration test in
tests/integration/test_dynamic_routes.pyto verifyon_loadevents trigger when navigating to the same static page multiple times
2 files reviewed, 2 comments
Edit PR Review Bot Settings | Greptile
CodSpeed Performance ReportMerging #5469 will not alter performanceComparing Summary
|
* memoize addEvents, which was being overwritten quite a bit * avoid sending the onLoadInternal when the app initially loads (as it will send hydrate itself)
…ession-on_load-not-called-when-navigating-to-same-page
…ocation Since the backend handles determining which on_load goes with the route, it will pick the correct one the first time, whether that's a real dynamic route or the actual 404 page.
Lendemor
approved these changes
Jun 25, 2025
masenf
added a commit
that referenced
this pull request
Jun 26, 2025
* always send on load even on going on the link * restore deps * make it closer to what nextjs was doing * avoid extra route change on_load * memoize addEvents, which was being overwritten quite a bit * avoid sending the onLoadInternal when the app initially loads (as it will send hydrate itself) * Avoid second on_load when 404 client side routing redirects to same location Since the backend handles determining which on_load goes with the route, it will pick the correct one the first time, whether that's a real dynamic route or the actual 404 page. --------- Co-authored-by: Masen Furer <m_github@0x26.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes a regression when moving off of nextjs