Skip to content
This repository was archived by the owner on May 4, 2020. It is now read-only.

Commit 86e087d

Browse files
authored
fix(intl-utils): prevent infinite recursion loop of getCanonicalRules (#591)
1 parent 7b6b57c commit 86e087d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/intl-utils/src/get-canonical-locales.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ export function getCanonicalLocales(locales?: string | string[]): string[] {
88
if (typeof getCanonicalLocales === 'function') {
99
return getCanonicalLocales(locales) as string[];
1010
}
11-
return Intl.NumberFormat.supportedLocalesOf(locales || '');
11+
// NOTE: we must NOT call `supportedLocalesOf` of a formatjs polyfill, or their implementation
12+
// will even eventually call this method recursively. Here we use `Intl.DateTimeFormat` since it
13+
// is not polyfilled by `@formatjs`.
14+
return Intl.DateTimeFormat.supportedLocalesOf(locales || '');
1215
}

0 commit comments

Comments
 (0)