Skip to content
Go back
🔄 회고

tWIL - 20년 12월 3째주

들어가며

개발

Dame24


func postContents(c echo.Context) (err error) {
	b := new(model.Book)
	if err = c.Bind(b); err != nil {
		return
	}

//... 생략

//...

json.NewDecoder(res.Body).Decode(&sr)

//...
// 커스텀 훅. 첫번째 인자는 키값이고 react-query 캐싱을 이용할때 쓰는 것 같다.

export function useSearchBook() {
  return useMutation("searchBook", async (title: string) => {
    return searchBookByName(title);
  });
}

// App.tsx

//..

const searchMutation = useSearchBook();
//..

const onSubmit = async ({ title }: FormData) => {
  searchInputRef.current?.focus();
  await searchMutation.mutate(title);
};
//..

searchMutation.isLoading; // 로딩 상태 true/false

//..

searchMutation.data;

//


프로젝트

회고

여담


Share this post on:

댓글


Previous Post
2020년 회고 (Work, Timeline)
Next Post
tWIL - 20년 12월 2째주