-
-
Notifications
You must be signed in to change notification settings - Fork 252
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
fix: add missing 'use client' directive for usePathname #189
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hey @wxh06, thanks for the PR. Does this improve the error in some way? The way I see it is that the component (or a parent) that uses If the error message is better with this fix, we could add it though (or generally to |
In fact, I had never used The error appears when trying to import anything from -import { NextIntlClientProvider } from "next-intl/client";
+import { NextIntlClientProvider } from "next-intl"; I guess the next-intl/packages/next-intl/src/client/index.tsx Lines 5 to 6 in f8fefd2
|
Yep, the import for
It's not a problem, but by design that you can't import client-only functionality on the server side. |
I mean using The code below does not work at all in 2.11.0-beta.8 as I mentioned in the description of this pr // app/[locale]/layout.tsx
import {NextIntlClientProvider} from 'next-intl/client';
import {notFound} from 'next/navigation';
export function generateStaticParams() {
return [{locale: 'en'}, {locale: 'de'}];
}
export default async function LocaleLayout({children, params: {locale}}) {
let messages;
try {
messages = (await import(`../../messages/${locale}.json`)).default;
} catch (error) {
notFound();
}
return (
<html lang={locale}>
<body>
<NextIntlClientProvider locale={locale} messages={messages}>
{children}
</NextIntlClientProvider>
</body>
</html>
);
} |
That's a fair point! Unfortunately, I wasn't aware of a way to deprecate the old import for I'll mark the latest beta version as a new major version and will include a note about upgrading in the documentation. Thanks! |
In fact, the current approach to reserving deprecated export of |
Oh, that's interesting, you're right! Sorry, now I finally see your point, I thought this would still print an error message! 🙂 Sounds good! |
Reference: https://beta.nextjs.org/docs/rendering/server-and-client-components#convention
Introduced in 68ce7db#diff-b67520fde3f77290ca84cfb11466b0d730d23909f7c67ee7150ee2888e9307b1R2
next-intl/packages/next-intl/src/client/usePathname.tsx
Line 2 in b301d47