Skip to content

Commit bb5774a

Browse files
committed
fix(i18n): strict mode causing i18n initialized twice
1 parent 7f5d8c1 commit bb5774a

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

next.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ module.exports = {
33
output: process.env.STANDALONE && 'standalone',
44
experimental: { instrumentationHook: true },
55
images: { remotePatterns: [{ hostname: 'source.unsplash.com' }] },
6-
rewrites: () => [{ source: '/api/wing/:path*', destination: `${process.env.WING_API_URL}/:path*` }]
6+
rewrites: () => [{ source: '/api/wing/:path*', destination: `${process.env.WING_API_URL}/:path*` }],
7+
reactStrictMode: false
78
}

src/app/bootstrap.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,21 @@
22

33
import dayjs from 'dayjs'
44
import duration from 'dayjs/plugin/duration'
5-
import { FC, ReactNode, useState } from 'react'
5+
import { FC, ReactNode } from 'react'
66
import { useAsync } from 'react-use'
77
import { LoadingSpinner } from '~/components/LoadingSpinner'
88
import { initializeEditor } from '~/editor'
99
import { initializeI18n } from '~/i18n'
1010

1111
export const Bootstrap: FC<{ children: ReactNode }> = ({ children }) => {
12-
const [loading, setLoading] = useState(true)
13-
14-
useAsync(async () => {
15-
setLoading(true)
16-
12+
const { loading } = useAsync(async () => {
1713
dayjs.extend(duration)
18-
await initializeI18n()
19-
await initializeEditor()
2014

21-
setLoading(false)
22-
})
15+
try {
16+
await initializeI18n()
17+
await initializeEditor()
18+
} catch {}
19+
}, [])
2320

2421
if (loading) {
2522
return (

src/i18n/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export const resources = {
2121
} as const
2222

2323
export const initializeI18n = async () => {
24-
await i18n.use(detectLanguage).use(initReactI18next).init({
25-
lng: LANG.enUS,
24+
await i18n.use(initReactI18next).use(detectLanguage).init({
2625
resources,
26+
fallbackLng: LANG.enUS,
2727
returnNull: false
2828
})
2929

0 commit comments

Comments
 (0)