-
-
Notifications
You must be signed in to change notification settings - Fork 257
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!: Inherit context in case nested NextIntlClientProvider
instances are present
#1413
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
messages: messages || prevContext?.messages, | ||
now: now || prevContext?.now, | ||
onError: onError || prevContext?.onError, | ||
timeZone: timeZone || prevContext?.timeZone |
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.
Doesn't minify terribly well, but can't really think of a better solution …
NextIntlClientProvider
ancestors are present
NextIntlClientProvider
ancestors are presentNextIntlClientProvider
instances are present
@amannn, thanks for your great work as always! I was wondering if it also makes sense to optionally allow the user to merge the existing and current messages as well, eg to support the nested providers where you provide essential client messages in the root layout, and then component-specific messages later down the tree? |
@dmitrc Thank you for the kind words and happy new year! Merging such messages is certainly an interesting use case, yes. Currently, you could achieve this manually in userland. Ideally, with #1, relevant messages for Client Components would be picked automatically—not requiring the developer to think in terms of "essential" client messages and "component-specific" ones. #1 and #962 are the two main features I'd like to explore next for Does that sound right to you? |
Yup, this makes complete sense, and I am incredibly excited about the improvements that solving #1 would bring! The only challenge in implementing it in userland is that it requires some opinionated setup:
Not too big of a deal, but the second bullet caught me by surprise a little :) |
If you have nested providers, previously only the configuration of the innermost one would be applied.
With this change, configuration is now passed from one provider to the next, while allowing to override individual props. This simplifies the configuration of
onError
andgetMessageFallback
if you're using those (see proposed docs).Breaking change: There's a very rare chance that this change affects your app, but in case you've previously relied on providers not inheriting from each other, you now have to reset props manually in case you want to retain the previous behavior.