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

292
Views
Múltiples consultas de Apollo en un componente, obtener no puede volver a declarar la variable de ámbito de bloque

Tengo estas dos consultas de Apollo en un componente de React:

 const { data, loading, error } = useQuery(PlaylistQuery, { variables: { _id: playlistId }, fetchPolicy: "cache-and-network", }); const [loadSong, { called, loading, error, data }] = useLazyQuery(SongQuery, { variables: { _id: song._id, }, });

Esto obviamente me dará este mensaje de error:

 Cannot redeclare block-scoped variable

¿Cuál es una forma inteligente de evitar esto?

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

0

Para evitar este problema, simplemente puede nombrar las variables de sus consultas. Como un ejemplo como a continuación:

 const { data: playListData, loading: playListLoading, error: playListError } = useQuery(PlaylistQuery, { variables: { _id: playlistId }, fetchPolicy: "cache-and-network", }); const [loadSong, { called: songFuctionCalled, loading: songLoading, error: songError, data :songData }] = useLazyQuery(SongQuery, { variables: { _id: song._id, }, });
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!