From 739ad7ef7c0f0315856777eb2ad4cec3b9904d33 Mon Sep 17 00:00:00 2001 From: arian Date: Mon, 18 Mar 2024 01:19:56 +0330 Subject: [PATCH 1/5] chore: update jotai version from 1.7.3 to 2.7.1 --- examples/with-jotai/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/with-jotai/package.json b/examples/with-jotai/package.json index d66058245fe33..d51ed0a2df26a 100644 --- a/examples/with-jotai/package.json +++ b/examples/with-jotai/package.json @@ -6,12 +6,13 @@ "start": "next start" }, "dependencies": { - "jotai": "1.7.3", + "jotai": "2.7.1", "next": "latest", "react": "18.2.0", "react-dom": "18.2.0" }, "devDependencies": { + "@types/node": "20.11.28", "@types/react": "17.0.16", "eslint": "7.32.0", "eslint-config-next": "11.0.1", From 646943cf39c5dc5bc34987b4005893edb134aefc Mon Sep 17 00:00:00 2001 From: arian Date: Mon, 18 Mar 2024 01:20:11 +0330 Subject: [PATCH 2/5] refactor: remove unused api endpoint --- examples/with-jotai/pages/api/hello.ts | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 examples/with-jotai/pages/api/hello.ts diff --git a/examples/with-jotai/pages/api/hello.ts b/examples/with-jotai/pages/api/hello.ts deleted file mode 100644 index ea77e8f35b382..0000000000000 --- a/examples/with-jotai/pages/api/hello.ts +++ /dev/null @@ -1,13 +0,0 @@ -// Next.js API route support: https://nextjs.org/docs/api-routes/introduction -import type { NextApiRequest, NextApiResponse } from "next"; - -type Data = { - name: string; -}; - -export default function handler( - req: NextApiRequest, - res: NextApiResponse, -) { - res.status(200).json({ name: "John Doe" }); -} From 262a4996bd6ec9037096bfdc2767d5bee10ebce8 Mon Sep 17 00:00:00 2001 From: arian Date: Mon, 18 Mar 2024 01:20:31 +0330 Subject: [PATCH 3/5] chore: migrate with-jotai example from page router to app router --- examples/with-jotai/app/layout.tsx | 22 +++++++++++++++++++ .../{pages/index.tsx => app/page.tsx} | 13 ++++++----- examples/with-jotai/components/Canvas.tsx | 2 ++ examples/with-jotai/pages/_app.tsx | 11 ---------- 4 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 examples/with-jotai/app/layout.tsx rename examples/with-jotai/{pages/index.tsx => app/page.tsx} (78%) delete mode 100644 examples/with-jotai/pages/_app.tsx diff --git a/examples/with-jotai/app/layout.tsx b/examples/with-jotai/app/layout.tsx new file mode 100644 index 0000000000000..cad34bcaaf7d5 --- /dev/null +++ b/examples/with-jotai/app/layout.tsx @@ -0,0 +1,22 @@ +import { Provider } from "jotai" +import { Metadata } from "next" + +export const metadata: Metadata = { + icons: '/favicon.ico' +} + +export default function RootLayout({ + children, +}: { + children: React.ReactNode +}) { + return ( + + + + {children} + + + + ) +} diff --git a/examples/with-jotai/pages/index.tsx b/examples/with-jotai/app/page.tsx similarity index 78% rename from examples/with-jotai/pages/index.tsx rename to examples/with-jotai/app/page.tsx index df98778f030b8..04187e7093d5a 100644 --- a/examples/with-jotai/pages/index.tsx +++ b/examples/with-jotai/app/page.tsx @@ -1,16 +1,17 @@ -import Head from "next/head"; import Image from "next/image"; import styles from "../styles/Home.module.css"; +import '../styles/globals.css' import Canvas from "../components/Canvas"; +import { Metadata } from "next"; + +export const metadata: Metadata = { + title: 'with-jotai', + description: 'Generated by create next app', + } export default function Home() { return (
- - with-jotai - - -

With Jotai example

diff --git a/examples/with-jotai/components/Canvas.tsx b/examples/with-jotai/components/Canvas.tsx index c87cba3dc84b0..6e17966913824 100644 --- a/examples/with-jotai/components/Canvas.tsx +++ b/examples/with-jotai/components/Canvas.tsx @@ -1,3 +1,5 @@ +'use client' + import { atom, useAtom } from "jotai"; type Point = [number, number]; diff --git a/examples/with-jotai/pages/_app.tsx b/examples/with-jotai/pages/_app.tsx deleted file mode 100644 index 8a2c747230d7d..0000000000000 --- a/examples/with-jotai/pages/_app.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import "../styles/globals.css"; -import type { AppProps } from "next/app"; -import { Provider } from "jotai"; - -export default function MyApp({ Component, pageProps }: AppProps) { - return ( - - - - ); -} From 69112490d933944ad99885104b17d42b505ed4fd Mon Sep 17 00:00:00 2001 From: arian Date: Mon, 18 Mar 2024 01:20:42 +0330 Subject: [PATCH 4/5] fix tsconfig.json --- examples/with-jotai/tsconfig.json | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/with-jotai/tsconfig.json b/examples/with-jotai/tsconfig.json index 4fa631c261428..6cdb40292ede4 100644 --- a/examples/with-jotai/tsconfig.json +++ b/examples/with-jotai/tsconfig.json @@ -1,19 +1,25 @@ { "compilerOptions": { - "target": "es5", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "strict": true, "forceConsistentCasingInFileNames": true, "noEmit": true, + "incremental": true, "esModuleInterop": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "preserve" + "jsx": "preserve", + "plugins": [ + { + "name": "next" + } + ], + "strictNullChecks": true }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"], "exclude": ["node_modules"] -} +} \ No newline at end of file From 642357ed83f2f37665fd2469744c42e4d7330555 Mon Sep 17 00:00:00 2001 From: arian Date: Tue, 19 Mar 2024 00:46:47 +0330 Subject: [PATCH 5/5] prettier files --- examples/with-jotai/app/layout.tsx | 16 +++++++--------- examples/with-jotai/app/page.tsx | 8 ++++---- examples/with-jotai/components/Canvas.tsx | 2 +- examples/with-jotai/tsconfig.json | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/examples/with-jotai/app/layout.tsx b/examples/with-jotai/app/layout.tsx index cad34bcaaf7d5..51f3d835719b9 100644 --- a/examples/with-jotai/app/layout.tsx +++ b/examples/with-jotai/app/layout.tsx @@ -1,22 +1,20 @@ -import { Provider } from "jotai" -import { Metadata } from "next" +import { Provider } from "jotai"; +import { Metadata } from "next"; export const metadata: Metadata = { - icons: '/favicon.ico' -} + icons: "/favicon.ico", +}; export default function RootLayout({ children, }: { - children: React.ReactNode + children: React.ReactNode; }) { return ( - - {children} - + {children} - ) + ); } diff --git a/examples/with-jotai/app/page.tsx b/examples/with-jotai/app/page.tsx index 04187e7093d5a..41a3d0e9860cd 100644 --- a/examples/with-jotai/app/page.tsx +++ b/examples/with-jotai/app/page.tsx @@ -1,13 +1,13 @@ import Image from "next/image"; import styles from "../styles/Home.module.css"; -import '../styles/globals.css' +import "../styles/globals.css"; import Canvas from "../components/Canvas"; import { Metadata } from "next"; export const metadata: Metadata = { - title: 'with-jotai', - description: 'Generated by create next app', - } + title: "with-jotai", + description: "Generated by create next app", +}; export default function Home() { return ( diff --git a/examples/with-jotai/components/Canvas.tsx b/examples/with-jotai/components/Canvas.tsx index 6e17966913824..f4a6602e2b1b3 100644 --- a/examples/with-jotai/components/Canvas.tsx +++ b/examples/with-jotai/components/Canvas.tsx @@ -1,4 +1,4 @@ -'use client' +"use client"; import { atom, useAtom } from "jotai"; diff --git a/examples/with-jotai/tsconfig.json b/examples/with-jotai/tsconfig.json index 6cdb40292ede4..6b98f2247f52d 100644 --- a/examples/with-jotai/tsconfig.json +++ b/examples/with-jotai/tsconfig.json @@ -22,4 +22,4 @@ }, "include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"], "exclude": ["node_modules"] -} \ No newline at end of file +}