“Zapytanie zależne od reakcji” Kod odpowiedzi

Zapytanie zależne od reakcji

// Get the user
2 const { data: user } = useQuery(['user', email], getUserByEmail)
3 
4 const userId = user?.id
5 
6 // Then get the user's projects
7 const { isIdle, data: projects } = useQuery(
8   ['projects', userId],
9   getProjectsByUser,
10   {
11     // The query will not execute until the userId exists
12     enabled: !!userId,
13   }
14 )
15 
16 // isIdle will be `true` until `enabled` is true and the query begins to fetch.
17 // It will then go to the `isLoading` stage and hopefully the `isSuccess` stage :)
Ms29Ash

Zapytanie zależne od reakcji

// Get the user
2 const { data: user } = useQuery(['user', email], getUserByEmail)
3 
4 const userId = user?.id
5 
6 // Then get the user's projects
7 const { isIdle, data: projects } = useQuery(
8   ['projects', userId],
9   getProjectsByUser,
10   {
11     // The query will not execute until the userId exists
12     enabled: !!userId,
13   }
14 )
15 
16 // isIdle will be `true` until `enabled` is true and the query begins to fetch.
17 // It will then go to the `isLoading` stage and hopefully the `isSuccess` stage :)
Ms29Ash

Odpowiedzi podobne do “Zapytanie zależne od reakcji”

Pytania podobne do “Zapytanie zależne od reakcji”

Więcej pokrewnych odpowiedzi na “Zapytanie zależne od reakcji” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu