refactor: deprecates params and search params contexts #9581
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.
As described in #9576, the
SearchParamsProvider
can become stale when navigating routes and relying on search params during initial render. This is because this context, along with theParamsProvider
, is duplicative to the internal lifecycle ofuseSearchParams
anduseParams
fromnext/navigation
– but always one render behind. Instead, we need to use the hooks directly fromnext/navigation
as described in the jsdocs. This will also remove any abstraction over top the web standard forURLSearchParams
.For this reason, these providers and their corresponding hooks have been marked with the deprecated flag and will continue to behave as they do now, but will be removed in the next major release. This PR replaces all internal reliance on these hooks with
next/navigation
as suggested, except for theuseParams
hook, which was never used in the first place.MyClientComponent.tsx