-
Notifications
You must be signed in to change notification settings - Fork 1
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
Read query params on initial load for events page #199
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason. clicking "Events" in the navbar doesn't reset the filters on the page:
- Go to home page
- Click on "See all events." This filters events by "Attended"
- Click on "Events" in the navbar. Nothing on the page changes, but the URL updates to
/events
Note: Experimented with using query params as a state but updating the browser's URL was laggy, so I left it out
- Maybe worth using a library for this?
What kind of lag are you experiencing? I think browsers will add some delay if you change the URL too often (like multiple times per second) to avoid crashing the browser
In my experience, using window.history.replaceState
is usually pretty fast, but I'm not sure how compatible it is with Next.js's router. this stackoverflow post says to use router.replace
instead, with shallow: true
to avoid reloading
it would be great to have that feature, though, so it doesn't get reset when you leave and come back, and it improves discoverability of the feature
I tried a different approach in #202 by handling query logic server-side to determine the initial value of the page state and leaving the client alone fully. I think it should solve the layout shift and route change issues we're facing here and be easier to maintain in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢 🚢 🚢
Info
Closes #187 .
Changes
Type of Change
expected)
linting/formatting)
workflows)
Testing
I have tested that my changes fully resolve the linked issue ...
Checklist
/src/lib/*
and commented hard to understand areasanywhere else.
Screenshots