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

193
Views
Función WatermelonDB Sync que genera un posible rechazo de promesa no controlada

Cada vez que hago clic en el botón para sincronizar la llamada, aparece: Error: Llamada de gancho no válida. Los ganchos solo se pueden llamar dentro del cuerpo de un componente de función. Esto podría suceder por una de las siguientes razones:

  1. Es posible que tenga versiones que no coincidan de React y el renderizador (como React DOM)
  2. Podrías estar rompiendo las Reglas de los Hooks
  3. Es posible que tenga más de una copia de React en la misma aplicación Consulte https://reactjs.org/link/invalid-hook-call para obtener consejos sobre cómo depurar y solucionar este problema.

¿Algunas ideas?

 import { synchronize } from '@nozbe/watermelondb/sync'; import { database } from '../../index'; const SYNC_API_URL = 'https://example.com/sync'; export async function sync() { await synchronize({ database, pullChanges: async ({lastPulledAt}) => { const response = await fetch(SYNC_API_URL, { method: 'GET', headers: {'Authorization': 'Bearer' + $(user.token)}, body: JSON.stringify({lastPulledAt}), }); if (!response.ok) { throw new Error(await response.text()); } const {changes, timestamp} = await response.json(); return {changes, timestamp}; }, pushChanges: async ({changes, lastPulledAt}) => { const response = await fetch( `${SYNC_API_URL}?lastPulledAt=${lastPulledAt}`, { method: 'POST', headers: {'Authorization': 'Bearer' + $(user.token)}, body: JSON.stringify(changes), }, ); if (!response.ok) { throw new Error(await response.text()); } }, }); }
about 4 years ago · Juan Pablo Isaza
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!