diff --git a/examples/with-react-intl/.gitignore b/examples/with-react-intl/.gitignore index a900ed2c9eaf9..46278d1684cee 100644 --- a/examples/with-react-intl/.gitignore +++ b/examples/with-react-intl/.gitignore @@ -35,3 +35,6 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +# i18n +compiled-lang \ No newline at end of file diff --git a/examples/with-react-intl/.npmrc b/examples/with-react-intl/.npmrc new file mode 100644 index 0000000000000..6c59086d86251 --- /dev/null +++ b/examples/with-react-intl/.npmrc @@ -0,0 +1 @@ +enable-pre-post-scripts=true diff --git a/examples/with-react-intl/.vscode/settings.json b/examples/with-react-intl/.vscode/settings.json deleted file mode 100644 index ad92582bd0913..0000000000000 --- a/examples/with-react-intl/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "editor.formatOnSave": true -} diff --git a/examples/with-react-intl/components/Layout.tsx b/examples/with-react-intl/components/Layout.tsx index 2110228a22514..ae0a719f27262 100644 --- a/examples/with-react-intl/components/Layout.tsx +++ b/examples/with-react-intl/components/Layout.tsx @@ -1,4 +1,4 @@ -import { ReactChild } from 'react' +import { ReactNode } from 'react' import { useIntl } from 'react-intl' import Head from 'next/head' import Nav from './Nav' @@ -6,27 +6,27 @@ import Nav from './Nav' interface LayoutProps { title?: string description?: string - children: ReactChild | ReactChild[] + children: ReactNode } export default function Layout({ title, description, children }: LayoutProps) { const intl = useIntl() + + title ||= intl.formatMessage({ + defaultMessage: 'React Intl Next.js Example', + description: 'Default document title', + }) + + description ||= intl.formatMessage({ + defaultMessage: 'This page is powered by Next.js', + description: 'Default document description', + }) + return ( <> - - - {title || - intl.formatMessage({ - defaultMessage: 'React Intl Next.js Example', - description: 'Default document title', - })} - {description || - intl.formatMessage({ - defaultMessage: 'This page is powered by Next.js', - description: 'Default document description', - })} - + {title} +