Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
Evite múltiples llamadas de red con ganchos y Apollo

Tengo un enlace que hace una llamada Graphql

 export const useGetStuff = (options?: QueryHookOptions<GetStuffResponse, GetStuffQueryArgs>) => { const [stuffId] = useStuffId(); return useQuery<GetStuffResponse, GetStuffQueryArgs>(getStuff, { variables: { stuffId }, notifyOnNetworkStatusChange: true, skip: !stuffId, ssr: false, ...options, }); };

Y estoy usando este gancho en otro gancho

 const useCustomHook = () => { // some unrelated stuff const { data: stuffData, loading } = useGetStuff(); // do logic with stuffData and other unrelated stuff return { someProperty }; }

y en algún componente, estoy usando useGetStuff y useCustomHook .

 const MyComponent = () => { const { someProperty } = useCustomHook(); const { data ,loading } = useGetStuff(); // stuff }

Esta implementación hace que la consulta getStuff se llame dos veces (dos llamadas de red).

¿Existe una manera simple de evitar eso sin tener que mantener useGetStuff solo en el enlace personalizado, ya que este último no debería devolver los datos de stuffData ?

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!