mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-24 22:36:22 +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 updateLocale from "dayjs/plugin/updateLocale";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import { useRouter } from "next/router";
|
||||
import * as React from "react";
|
||||
import { useAsync } from "react-use";
|
||||
|
||||
|
@ -188,7 +189,8 @@ export const DayjsProvider: React.FunctionComponent<{
|
|||
};
|
||||
};
|
||||
}> = ({ config, children }) => {
|
||||
const l = config?.locale ?? "en";
|
||||
const router = useRouter();
|
||||
const l = config?.locale ?? router.locale ?? "en";
|
||||
const state = useAsync(async () => {
|
||||
return await dayjsLocales[l].import();
|
||||
}, [l]);
|
||||
|
@ -249,7 +251,6 @@ export const ConnectedDayjsProvider = ({
|
|||
children,
|
||||
}: React.PropsWithChildren) => {
|
||||
const { preferences } = usePreferences();
|
||||
|
||||
return (
|
||||
<DayjsProvider
|
||||
config={{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue