mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-25 06:46:23 +02:00
🐛 Fix dayjs locale should default to router locale
This commit is contained in:
parent
7c54268b58
commit
c6b17aa22b
1 changed files with 3 additions and 2 deletions
|
@ -11,6 +11,7 @@ import relativeTime from "dayjs/plugin/relativeTime";
|
||||||
import timezone from "dayjs/plugin/timezone";
|
import timezone from "dayjs/plugin/timezone";
|
||||||
import updateLocale from "dayjs/plugin/updateLocale";
|
import updateLocale from "dayjs/plugin/updateLocale";
|
||||||
import utc from "dayjs/plugin/utc";
|
import utc from "dayjs/plugin/utc";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { useAsync } from "react-use";
|
import { useAsync } from "react-use";
|
||||||
|
|
||||||
|
@ -188,7 +189,8 @@ export const DayjsProvider: React.FunctionComponent<{
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}> = ({ config, children }) => {
|
}> = ({ config, children }) => {
|
||||||
const l = config?.locale ?? "en";
|
const router = useRouter();
|
||||||
|
const l = config?.locale ?? router.locale ?? "en";
|
||||||
const state = useAsync(async () => {
|
const state = useAsync(async () => {
|
||||||
return await dayjsLocales[l].import();
|
return await dayjsLocales[l].import();
|
||||||
}, [l]);
|
}, [l]);
|
||||||
|
@ -249,7 +251,6 @@ export const ConnectedDayjsProvider = ({
|
||||||
children,
|
children,
|
||||||
}: React.PropsWithChildren) => {
|
}: React.PropsWithChildren) => {
|
||||||
const { preferences } = usePreferences();
|
const { preferences } = usePreferences();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DayjsProvider
|
<DayjsProvider
|
||||||
config={{
|
config={{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue