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:
¿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()); } }, }); }