Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update nextjs implementation to react 18 (#1987)
Fixing some problems with botched route implemenations as well
- Loading branch information
1 parent
dae362e
commit ada5ff0
Showing
76 changed files
with
616 additions
and
673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import App from "next/app"; | ||
import App from 'next/app'; | ||
import Nav from '../components/nav'; | ||
|
||
function MyApp({Component, pageProps}) { | ||
return ( | ||
<> | ||
<Nav/> | ||
<Component {...pageProps} /> | ||
</> | ||
); | ||
function MyApp({ Component, pageProps }) { | ||
return ( | ||
<> | ||
<Nav /> | ||
<Component {...pageProps} /> | ||
</> | ||
); | ||
} | ||
|
||
MyApp.getInitialProps = async ctx => { | ||
const appProps = await App.getInitialProps(ctx); | ||
return appProps | ||
} | ||
const appProps = await App.getInitialProps(ctx); | ||
return appProps; | ||
}; | ||
export default MyApp; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const HelloWorld = () => { | ||
return <>Hello World</> | ||
} | ||
return <>Hello World</>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
import { createFederatedCatchAll } from 'nextjs-shared'; | ||
|
||
export default createFederatedCatchAll(['home', 'shop']); | ||
import dynamic from 'next/dynamic'; | ||
const page = import('../realPages/[...slug]'); | ||
const Page = dynamic(() => import('../realPages/[...slug]')); | ||
Page.getInitialProps = async ctx => { | ||
const getInitialProps = (await page).default?.getInitialProps; | ||
if (getInitialProps) { | ||
return getInitialProps(ctx); | ||
} | ||
return {}; | ||
}; | ||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
import { Suspense } from 'react'; | ||
import App from 'next/app'; | ||
import dynamic from 'next/dynamic'; | ||
const Nav = dynamic( | ||
() => { | ||
const mod = import('home/nav'); | ||
console.log(mod); | ||
return mod; | ||
}, | ||
{ ssr: false }, | ||
); | ||
const page = import('../realPages/_app'); | ||
|
||
function MyApp({ Component, pageProps }) { | ||
return ( | ||
<> | ||
<Nav /> | ||
<Component {...pageProps} /> | ||
</> | ||
); | ||
} | ||
const Page = dynamic(() => import('../realPages/_app')); | ||
Page.getInitialProps = async ctx => { | ||
const appProps = await App.getInitialProps(ctx); | ||
|
||
export default MyApp; | ||
const getInitialProps = (await page).default?.getInitialProps; | ||
if (getInitialProps) { | ||
return { | ||
...appProps, | ||
...getInitialProps(ctx), | ||
}; | ||
} | ||
return { ...appProps }; | ||
}; | ||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,12 @@ | ||
import React from 'react'; | ||
import Head from 'next/head'; | ||
import dynamic from 'next/dynamic'; | ||
const page = import('../realPages/checkout'); | ||
|
||
const Checkout = props => ( | ||
<div> | ||
<Head> | ||
<title>checkout</title> | ||
<link rel="icon" href="/favicon.ico" /> | ||
</Head> | ||
|
||
<div className="hero"> | ||
<h1>checkout page</h1> | ||
<h3 className="title">This is a federated page owned by localhost:3000</h3> | ||
<span> | ||
{' '} | ||
Data from federated <pre>getInitalProps</pre> | ||
</span> | ||
<br /> | ||
<pre>{JSON.stringify(props, null, 2)}</pre> | ||
</div> | ||
<style jsx>{` | ||
.hero { | ||
width: 100%; | ||
color: #333; | ||
} | ||
.title { | ||
margin: 0; | ||
width: 100%; | ||
padding-top: 80px; | ||
line-height: 1.15; | ||
font-size: 20px; | ||
} | ||
.title, | ||
.description { | ||
text-align: center; | ||
} | ||
`}</style> | ||
</div> | ||
); | ||
Checkout.getInitialProps = async () => { | ||
const swapi = await fetch('https://jsonplaceholder.typicode.com/todos/1').then(res => res.json()); | ||
return swapi; | ||
const Page = dynamic(() => import('../realPages/checkout')); | ||
Page.getInitialProps = async ctx => { | ||
const getInitialProps = (await page).default?.getInitialProps; | ||
if (getInitialProps) { | ||
return getInitialProps(ctx); | ||
} | ||
return {}; | ||
}; | ||
export default Checkout; | ||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
import { createFederatedCatchAll } from 'nextjs-shared'; | ||
import dynamic from 'next/dynamic'; | ||
const page = import('../realPages/index'); | ||
|
||
export default createFederatedCatchAll(['home', 'shop']); | ||
const Page = dynamic(() => import('../realPages/index')); | ||
Page.getInitialProps = async ctx => { | ||
const getInitialProps = (await page).default?.getInitialProps; | ||
if (getInitialProps) { | ||
return getInitialProps(ctx); | ||
} | ||
return {}; | ||
}; | ||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,12 @@ | ||
import React from 'react'; | ||
import Head from 'next/head'; | ||
import dynamic from 'next/dynamic'; | ||
const page = import('../../realPages/shop/mybag'); | ||
|
||
const MyBag = props => ( | ||
<div> | ||
<Head> | ||
<title>My Bag</title> | ||
<link rel="icon" href="/favicon.ico" /> | ||
</Head> | ||
|
||
<div className="hero"> | ||
<h1>my bag page</h1> | ||
<h3 className="title">This is a federated page, consumed by localhost:3001</h3> | ||
<br /> | ||
</div> | ||
<style jsx>{` | ||
.hero { | ||
width: 100%; | ||
color: #333; | ||
} | ||
.title { | ||
margin: 0; | ||
width: 100%; | ||
padding-top: 80px; | ||
line-height: 1.15; | ||
font-size: 20px; | ||
} | ||
.title, | ||
.description { | ||
text-align: center; | ||
} | ||
`}</style> | ||
</div> | ||
); | ||
MyBag.getInitialProps = async () => { | ||
const swapi = await fetch('https://swapi.dev/api/people/1').then(res => res.json()); | ||
return swapi; | ||
const Page = dynamic(() => import('../../realPages/shop/mybag')); | ||
Page.getInitialProps = async ctx => { | ||
const getInitialProps = (await page).default?.getInitialProps; | ||
if (getInitialProps) { | ||
return getInitialProps(ctx); | ||
} | ||
return {}; | ||
}; | ||
export default MyBag; | ||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,6 @@ | ||
import { createFederatedCatchAll } from 'nextjs-shared'; | ||
|
||
export default createFederatedCatchAll(['home', 'shop']); | ||
|
||
import dynamic from 'next/dynamic'; | ||
const page = import('../realPages/[...slug]'); | ||
|
||
const Page = dynamic(() => page); | ||
Page.getInitialProps = async ctx => { | ||
const getInitialProps = await page.default?.getInitialProps; | ||
if (getInitialProps) { | ||
return getInitialProps(ctx); | ||
} | ||
return {}; | ||
}; | ||
export default Page; |
Oops, something went wrong.