-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
feat: Add search params cache #397
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
9e7ade4
to
86a323d
Compare
bb00080
to
33f32e8
Compare
33f32e8
to
09330cf
Compare
7d7106f
to
74543f4
Compare
74543f4
to
c5318ae
Compare
c5318ae
to
1f4a44a
Compare
Edit: it still makes sense. |
Yes, It definitely has value in terms of preventing prop drilling in server components. Good stuff! I have learned something new from this PR. |
617b292
to
77c6acc
Compare
CI is failing with the weirdest bug.. Changing the cache test case by adding two children pages Edit: links are not at fault, it's just the mere presence of the second child page. Even if both of them contains a simple static Hello world. Starting to question my sanity here. |
How about when you are using router.push to go to page b? |
Ah sorry I missed the part. Yea I don't think we should worry about the page router since it is not designed for RSC(cache is part of the RSC proposal) and I don't think Next.js team would fix it even you report it. |
Actually it made me realise the e2e test did not properly catch the underlying issue: basePath support is broken on the pages router at the moment, and the issue above only uncovered the problem in another way. But running the e2e test bench shows the basePath not being properly handled. I'll rework those tests in a separate PR. As for the cache, I think it's good to go, there should be an error thrown at build time if it's being used in a Layout (or any component under a layout), to highlight the fact that even though Layouts may receive searchParams via the cache feature on page reload, it goes stale instantly on client-side navigation, so it should not be trusted. |
What the actual freaking fuck? The mere presence of those pages (in the app router), and even if they only were to contain a static Hello world output, would cause the **pages** router to fail to apply updates, when there is a basePath, and on Next.js 13.5+. Losing sanity here trying to figure out what's wrong, and it's the middle of the night so I won't go deeper into this right now. See #397 (comment)
b45b16a
to
7c2ef46
Compare
This simplifies the use of parsers on the server, and allows accessing search params in a type-safe manner in deeply nested server components. Big thanks to @eric-burel for the tip on how to use React's `cache` this way.
Running out of relevant HTTP status codes.. Maybe this was a bad idea.
This allows accessing the parsed values straight from the page component. Freezing also ensures the object reference stays immutable for the whole duration of the page render.
Cache can't be exported from the page file, so instead showcase the "soft convention" of using a searchParams.ts file next to the page.
What the actual freaking fuck? The mere presence of those pages (in the app router), and even if they only were to contain a static Hello world output, would cause the **pages** router to fail to apply updates, when there is a basePath, and on Next.js 13.5+. Losing sanity here trying to figure out what's wrong, and it's the middle of the night so I won't go deeper into this right now. See #397 (comment)
7c2ef46
to
57b7f85
Compare
🎉 This PR is included in version 1.13.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This simplifies the use of parsers on the server, and allows accessing search params in a type-safe manner in deeply nested server components.
Big thanks to @eric-burel for the tip on how to use React's
cache
this way.Test that cache is indeed empty in layouts (NUQS-500)-> It's not, if the whole page is switched to dynamic rendering