-
-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathclient-page.js
42 lines (36 loc) · 1.21 KB
/
client-page.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import Link from 'next/link'
import { useTranslation } from 'next-i18next'
// import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import { Header } from '../components/Header'
import { Footer } from '../components/Footer'
const ClientPage = () => {
const { t, ready, i18n } = useTranslation(['client-page', 'footer'])
if (!ready) return 'loading translations...'
// but because of this ready return, you may see a warning like this: "Expected server HTML to contain a matching text node for..."
return (
<>
<main>
<Header heading={t('h1')} title={t('title')} />
<Link href='/'>
<button
type='button'
>
{t('back-to-home')}
</button>
</Link>
</main>
<Footer />
</>
)
}
// ADVICE: I suggest you don't use this client-side only approach, but use the lazy-reload approach instead!
//
// Without the getStaticProps or getServerSideProps function,
// the translsations are loaded via configured i18next backend.
//
// export const getStaticProps = async ({ locale }) => ({
// props: {
// ...await serverSideTranslations(locale, ['client-page', 'footer']),
// },
// })
export default ClientPage