macmeals / todo_context_typescript

TodoリストのTypeScript化
0 stars 0 forks source link

useTextGet.ts #23

Closed macmeals closed 2 years ago

macmeals commented 2 years ago

Issue

#14

内容

①useTextGet.tsの中の型名を「JsonPlace」から「Todo」へ変更しました。 useTextGet.ts

type Todo = {
  userId: number;
  id: number;
  title: string;
  completed: boolean;
};

const { data } = await axios.get<Todo[]>(url);

②関数の名前「jsonFetch」を「titleFetch」へ変更しました。 useTextGet.ts const titleFetch = useCallback(async () => { return { textTitle, titleFetch };

TodoLists.tsx

const { textTitle, titleFetch } = useTextGet();
useEffect(() => {
    titleFetch();
  }, []);