Skip to content

Commit fecfdb9

Browse files
committed
refactor
1 parent 42a4684 commit fecfdb9

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

examples/11_nextjs_app_router/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "11_nextjs_app_router",
2+
"name": "jotai-tanstack-query-example-nextjs-app-router",
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export async function getPost(postId: string) {
2+
console.debug('getPost called with postId:', postId)
3+
const res = await fetch(
4+
`https://jsonplaceholder.typicode.com/posts/${postId}`
5+
)
6+
return res.json()
7+
}

examples/11_nextjs_app_router/src/app/posts/[postId]/page.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@ import {
55
dehydrate,
66
} from '@tanstack/react-query'
77
import { Post } from './_components/post'
8-
9-
export async function getPost(postId: string) {
10-
console.debug('getPost called with postId:', postId)
11-
const res = await fetch(
12-
`https://jsonplaceholder.typicode.com/posts/${postId}`
13-
)
14-
return res.json()
15-
}
8+
import { getPost } from '@/app/api'
169

1710
export default async function PostPage({
1811
params,

examples/11_nextjs_app_router/src/app/stores.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { atom } from 'jotai'
22
import { atomWithQuery } from 'jotai-tanstack-query'
3-
import { getPost } from './posts/[postId]/page'
3+
import { getPost } from './api'
44

55
export const postIdAtom = atom<string>('1')
66
export const postQueryAtom = atomWithQuery((get) => ({

0 commit comments

Comments
 (0)