diff --git a/src/App/components/Loading/Loading.test.tsx b/src/App/components/Loading/Loading.test.tsx index 61f55db..18cf3ac 100644 --- a/src/App/components/Loading/Loading.test.tsx +++ b/src/App/components/Loading/Loading.test.tsx @@ -19,9 +19,9 @@ describe('Loading', () => { }); test('Displays given error', () => { - const message = 'given error'; + const error = { name: 'HttpError', message: 'given error', status: 0 }; render( - + {children} , ); diff --git a/src/App/components/Loading/Loading.tsx b/src/App/components/Loading/Loading.tsx index 82e3169..44e125f 100644 --- a/src/App/components/Loading/Loading.tsx +++ b/src/App/components/Loading/Loading.tsx @@ -1,10 +1,10 @@ import { FC, ReactNode } from 'react'; import Info from '../Info'; -import type { Status, Error } from '@/types'; +import type { Status, HttpError } from '@/types'; interface LoadingProps { status: Status; - error: Error | null; + error: HttpError | null; children: ReactNode; } diff --git a/src/App/components/Post/useData.ts b/src/App/components/Post/useData.ts index c162482..4a3faeb 100644 --- a/src/App/components/Post/useData.ts +++ b/src/App/components/Post/useData.ts @@ -1,12 +1,12 @@ import { useQuery } from '@tanstack/react-query'; import { getJson } from '@/api'; -import type { PostData } from '@/types'; +import type { PostData, HttpError } from '@/types'; const fetchPostById = async (id: number) => await getJson(`posts/${id}`); const useData = (postId: number) => - useQuery(['post', postId], () => fetchPostById(postId), { + useQuery(['post', postId], () => fetchPostById(postId), { enabled: !!postId, }); diff --git a/src/App/components/Posts/Posts.tsx b/src/App/components/Posts/Posts.tsx index 4271745..d1174b3 100644 --- a/src/App/components/Posts/Posts.tsx +++ b/src/App/components/Posts/Posts.tsx @@ -5,6 +5,7 @@ import css from './Posts.module.css'; import Info from '../Info'; import Loading from '../Loading'; import useData from './useData'; +import { PostData } from '@/types'; interface PostsProps { setPostId: (id: number | null) => void; @@ -25,7 +26,7 @@ const Posts: FC = ({ setPostId }) => { Background Updating