Skip to content

Commit

Permalink
Create component to allow use NextIntlClientProvider on async components
Browse files Browse the repository at this point in the history
following the owner of the library comment: amannn/next-intl#406 (comment)
  • Loading branch information
tomivm committed Mar 20, 2024
1 parent dd3940f commit 12c9d9a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/IntlWrapperForAsync/IntlWrapperForAsync.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NextIntlClientProvider, useMessages } from 'next-intl';
import pick from 'lodash.pick';

export default function IntlWrapperForAsync({
children,
propertyName,
}: {
children: React.ReactNode;
propertyName: string;
}) {
const messages = useMessages();
return (
<NextIntlClientProvider messages={pick(messages, propertyName)}>
{children}
</NextIntlClientProvider>
);
}

0 comments on commit 12c9d9a

Please sign in to comment.