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

126
Views
Comprobación de variable fuera de su alcance

En mi código, quiero ejecutar una consulta condicionalmente y luego verificar su variable de carga dentro de la plantilla, pero solo si la consulta se ejecuta y no quiero tener ningún error de TypeScript en mi archivo. ¿Cómo verifico esta variable que podría o no existir en su contexto?

Estoy usando Apollo GraphQL.

 if( executeMyQuery ) { const { data, loading: loadingQuery } = useQuery( MyQuery ); } return ( <View> { /* ... some code ... */ } { executeMyQuery && loadingQuery ? <Text>Query is loading...</Text> { /* ... some code ... */ } : null } </View> );

TypeScript dice: Cannot find name 'loadingQuery'.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Eche un vistazo a las consultas dependientes

 const { data, loading: loadingQuery } = useQuery( MyQuery, { // The query will not execute until the userId exists enabled: executeMyQuery, } ); return ( <View> { /* ... some code ... */ } { executeMyQuery && loadingQuery ? <Text>Query is loading...</Text> { /* ... some code ... */ } : null } </View> );
about 4 years ago · Juan Pablo Isaza Report

0

Se arregló usando el parámetro de skip cambiando

 if( executeMyQuery ) { const { data, loading: loadingQuery } = useQuery( MyQuery ); }

A

 const { data, loading: loadingQuery } = useQuery( MyQuery, { skip: executeMyQuery, } );
about 4 years ago · Juan Pablo Isaza Report
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!