File tree Expand file tree Collapse file tree 4 files changed +10
-10
lines changed
examples/11_nextjs_app_router Expand file tree Collapse file tree 4 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -5,14 +5,7 @@ import {
55 dehydrate ,
66} from '@tanstack/react-query'
77import { 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
1710export default async function PostPage ( {
1811 params,
Original file line number Diff line number Diff line change 11import { atom } from 'jotai'
22import { atomWithQuery } from 'jotai-tanstack-query'
3- import { getPost } from './posts/[postId]/page '
3+ import { getPost } from './api '
44
55export const postIdAtom = atom < string > ( '1' )
66export const postQueryAtom = atomWithQuery ( ( get ) => ( {
You can’t perform that action at this time.
0 commit comments