2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

UseQuery を複数使う場合

Posted at

備忘録。

Apollo の useQuery を使う時、複数の data で名前がかぶってしまう問題があります。

const {data, loading, error} = useQuery(SOME_QUERY1)
const {data, loading, error} = useQuery(SOME_QUERY2)

このような場合は、次のようにコードを書けば、複数の data があっても名前がかぶることはありません。

const {data: data1, loading: loading1, error: error1} = useQuery(SOME_QUERY1)
const {data: data2, loading: loading2, error: error2} = useQuery(SOME_QUERY2)

// 呼び出しは、data1, loading1, error1 などでする

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?