From 016da32161bdf551cd6e5528c7a7ee9d6c367f2f Mon Sep 17 00:00:00 2001 From: illiakovalenko Date: Tue, 13 Sep 2022 15:13:54 +0200 Subject: [PATCH 1/3] [NextJs] Specify AppProps generic type in _app.tsx to align with latest changes from Next 12.3.0 --- .../templates/nextjs-styleguide/src/pages/_app.tsx | 3 ++- .../src/templates/nextjs-sxa/src/pages/_app.tsx | 3 ++- .../src/templates/nextjs/src/lib/page-props.ts | 12 +++++++++--- .../src/templates/nextjs/src/pages/_app.tsx | 3 ++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/pages/_app.tsx b/packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/pages/_app.tsx index a440db6348..d56907b085 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/pages/_app.tsx +++ b/packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/pages/_app.tsx @@ -2,6 +2,7 @@ import type { AppProps } from 'next/app'; import Router from 'next/router'; import { I18nProvider } from 'next-localization'; import NProgress from 'nprogress'; +import { NextAppProps } from 'lib/page-props'; // Using bootstrap and nprogress are completely optional. // bootstrap is used here to provide a clean layout for samples, without needing extra CSS in the sample app @@ -17,7 +18,7 @@ Router.events.on('routeChangeStart', () => NProgress.start()); Router.events.on('routeChangeComplete', () => NProgress.done()); Router.events.on('routeChangeError', () => NProgress.done()); -function App({ Component, pageProps }: AppProps): JSX.Element { +function App({ Component, pageProps }: AppProps): JSX.Element { const { dictionary, ...rest } = pageProps; return ( diff --git a/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/_app.tsx b/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/_app.tsx index d1d67549c6..ed307ceee8 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/_app.tsx +++ b/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/_app.tsx @@ -1,9 +1,10 @@ import type { AppProps } from 'next/app'; import { I18nProvider } from 'next-localization'; +import { NextAppProps } from 'lib/page-props'; import 'assets/main.scss'; -function App({ Component, pageProps }: AppProps): JSX.Element { +function App({ Component, pageProps }: AppProps): JSX.Element { const { dictionary, ...rest } = pageProps; return ( diff --git a/packages/create-sitecore-jss/src/templates/nextjs/src/lib/page-props.ts b/packages/create-sitecore-jss/src/templates/nextjs/src/lib/page-props.ts index 79c84d1c47..3b0512aba2 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs/src/lib/page-props.ts +++ b/packages/create-sitecore-jss/src/templates/nextjs/src/lib/page-props.ts @@ -6,13 +6,19 @@ import { } from '@sitecore-jss/sitecore-jss-nextjs'; /** - * Sitecore page props + * Nextjs app props */ -export type SitecorePageProps = { +export type NextAppProps = { locale: string; dictionary: DictionaryPhrases; + layoutData: LayoutServiceData; componentProps: ComponentPropsCollection; +}; + +/** + * Sitecore page props + */ +export type SitecorePageProps = NextAppProps & { notFound: boolean; - layoutData: LayoutServiceData; redirect?: Redirect; }; diff --git a/packages/create-sitecore-jss/src/templates/nextjs/src/pages/_app.tsx b/packages/create-sitecore-jss/src/templates/nextjs/src/pages/_app.tsx index e0a45e1361..345dd1caaf 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs/src/pages/_app.tsx +++ b/packages/create-sitecore-jss/src/templates/nextjs/src/pages/_app.tsx @@ -1,9 +1,10 @@ import type { AppProps } from 'next/app'; import { I18nProvider } from 'next-localization'; +import { NextAppProps } from 'lib/page-props'; import 'assets/app.css'; -function App({ Component, pageProps }: AppProps): JSX.Element { +function App({ Component, pageProps }: AppProps): JSX.Element { const { dictionary, ...rest } = pageProps; return ( From 226d6853584891d39909a70dae7bb85e978fe2c8 Mon Sep 17 00:00:00 2001 From: illiakovalenko Date: Thu, 15 Sep 2022 18:13:41 +0200 Subject: [PATCH 2/3] Use SitecorePageProps --- .../templates/nextjs-styleguide/src/pages/_app.tsx | 4 ++-- .../src/templates/nextjs-sxa/src/pages/_app.tsx | 4 ++-- .../src/templates/nextjs/src/lib/page-props.ts | 14 ++++---------- .../src/templates/nextjs/src/pages/_app.tsx | 4 ++-- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/pages/_app.tsx b/packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/pages/_app.tsx index d56907b085..36fa2b36ef 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/pages/_app.tsx +++ b/packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/pages/_app.tsx @@ -2,7 +2,7 @@ import type { AppProps } from 'next/app'; import Router from 'next/router'; import { I18nProvider } from 'next-localization'; import NProgress from 'nprogress'; -import { NextAppProps } from 'lib/page-props'; +import { SitecorePageProps } from 'lib/page-props'; // Using bootstrap and nprogress are completely optional. // bootstrap is used here to provide a clean layout for samples, without needing extra CSS in the sample app @@ -18,7 +18,7 @@ Router.events.on('routeChangeStart', () => NProgress.start()); Router.events.on('routeChangeComplete', () => NProgress.done()); Router.events.on('routeChangeError', () => NProgress.done()); -function App({ Component, pageProps }: AppProps): JSX.Element { +function App({ Component, pageProps }: AppProps): JSX.Element { const { dictionary, ...rest } = pageProps; return ( diff --git a/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/_app.tsx b/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/_app.tsx index ed307ceee8..7bbf99b96c 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/_app.tsx +++ b/packages/create-sitecore-jss/src/templates/nextjs-sxa/src/pages/_app.tsx @@ -1,10 +1,10 @@ import type { AppProps } from 'next/app'; import { I18nProvider } from 'next-localization'; -import { NextAppProps } from 'lib/page-props'; +import { SitecorePageProps } from 'lib/page-props'; import 'assets/main.scss'; -function App({ Component, pageProps }: AppProps): JSX.Element { +function App({ Component, pageProps }: AppProps): JSX.Element { const { dictionary, ...rest } = pageProps; return ( diff --git a/packages/create-sitecore-jss/src/templates/nextjs/src/lib/page-props.ts b/packages/create-sitecore-jss/src/templates/nextjs/src/lib/page-props.ts index 3b0512aba2..75912ceda7 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs/src/lib/page-props.ts +++ b/packages/create-sitecore-jss/src/templates/nextjs/src/lib/page-props.ts @@ -6,19 +6,13 @@ import { } from '@sitecore-jss/sitecore-jss-nextjs'; /** - * Nextjs app props + * Sitecore page props */ -export type NextAppProps = { +export type SitecorePageProps = { + notFound: boolean; + redirect?: Redirect; locale: string; dictionary: DictionaryPhrases; layoutData: LayoutServiceData; componentProps: ComponentPropsCollection; }; - -/** - * Sitecore page props - */ -export type SitecorePageProps = NextAppProps & { - notFound: boolean; - redirect?: Redirect; -}; diff --git a/packages/create-sitecore-jss/src/templates/nextjs/src/pages/_app.tsx b/packages/create-sitecore-jss/src/templates/nextjs/src/pages/_app.tsx index 345dd1caaf..7fef8a5794 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs/src/pages/_app.tsx +++ b/packages/create-sitecore-jss/src/templates/nextjs/src/pages/_app.tsx @@ -1,10 +1,10 @@ import type { AppProps } from 'next/app'; import { I18nProvider } from 'next-localization'; -import { NextAppProps } from 'lib/page-props'; +import { SitecorePageProps } from 'lib/page-props'; import 'assets/app.css'; -function App({ Component, pageProps }: AppProps): JSX.Element { +function App({ Component, pageProps }: AppProps): JSX.Element { const { dictionary, ...rest } = pageProps; return ( From 90d7c8e39e2c6535f67d601e8e3a125dca754269 Mon Sep 17 00:00:00 2001 From: illiakovalenko Date: Thu, 15 Sep 2022 18:14:54 +0200 Subject: [PATCH 3/3] revert --- .../src/templates/nextjs/src/lib/page-props.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/create-sitecore-jss/src/templates/nextjs/src/lib/page-props.ts b/packages/create-sitecore-jss/src/templates/nextjs/src/lib/page-props.ts index 75912ceda7..79c84d1c47 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs/src/lib/page-props.ts +++ b/packages/create-sitecore-jss/src/templates/nextjs/src/lib/page-props.ts @@ -9,10 +9,10 @@ import { * Sitecore page props */ export type SitecorePageProps = { - notFound: boolean; - redirect?: Redirect; locale: string; dictionary: DictionaryPhrases; - layoutData: LayoutServiceData; componentProps: ComponentPropsCollection; + notFound: boolean; + layoutData: LayoutServiceData; + redirect?: Redirect; };