Skip to content

Commit

Permalink
Migrate the with-jotai example from page router to app router (#63390)
Browse files Browse the repository at this point in the history
## Migrate the with-jotai example from page router to app router

Please if it needs further updates, Let me know!
Happy to contribute

---------

Co-authored-by: Sam Ko <sam@vercel.com>
  • Loading branch information
ariannargesi and samcx committed Mar 18, 2024
1 parent e12535c commit a2e3b27
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 34 deletions.
20 changes: 20 additions & 0 deletions examples/with-jotai/app/layout.tsx
@@ -0,0 +1,20 @@
import { Provider } from "jotai";
import { Metadata } from "next";

export const metadata: Metadata = {
icons: "/favicon.ico",
};

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body>
<Provider>{children}</Provider>
</body>
</html>
);
}
@@ -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 (
<div className={styles.container}>
<Head>
<title>with-jotai</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<h1 className={styles.title}>With Jotai example</h1>
<main className={styles.main}>
<Canvas />
Expand Down
2 changes: 2 additions & 0 deletions examples/with-jotai/components/Canvas.tsx
@@ -1,3 +1,5 @@
"use client";

import { atom, useAtom } from "jotai";

type Point = [number, number];
Expand Down
3 changes: 2 additions & 1 deletion examples/with-jotai/package.json
Expand Up @@ -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",
Expand Down
11 changes: 0 additions & 11 deletions examples/with-jotai/pages/_app.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions examples/with-jotai/pages/api/hello.ts

This file was deleted.

12 changes: 9 additions & 3 deletions 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"]
}

0 comments on commit a2e3b27

Please sign in to comment.