Skip to content

Commit

Permalink
fix: update promise type (#431)
Browse files Browse the repository at this point in the history
* fix: update promise type

* chore: update documentation

---------

Co-authored-by: Tom Lienard <[email protected]>
  • Loading branch information
blechatellier and QuiiBz authored Oct 31, 2024
1 parent c332633 commit 4e873d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions docs/pages/docs/app-get-change-locale.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ export default function Page() {
// Server Component
import { getCurrentLocale } from '../../locales/server'

export default function Page() {
const locale = getCurrentLocale()
export default async function Page() {
// If you are using Next.js < 15, you don't need to await `getCurrentLocale`:
// const locale = getCurrentLocale()
const locale = await getCurrentLocale()

return (
<p>Current locale: {locale}</p>
Expand Down
2 changes: 1 addition & 1 deletion packages/next-international/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-international",
"version": "1.3.0",
"version": "1.3.1",
"description": "Type-safe internationalization (i18n) for Next.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getLocaleCache } from './get-locale-cache';

export function createGetCurrentLocale<LocalesKeys>(): () => LocalesKeys {
export function createGetCurrentLocale<LocalesKeys>(): () => Promise<LocalesKeys> {
return function getCurrentLocale() {
return getLocaleCache() as LocalesKeys;
return getLocaleCache() as Promise<LocalesKeys>;
};
}

0 comments on commit 4e873d1

Please sign in to comment.