Skip to content

Commit ffa22f6

Browse files
authored
Merge pull request #11 from StudioLambda/fix/useeffectevent-render-emission
Fix useEffectEvent render-phase violation from synchronous emit()
2 parents 60c9377 + b9c168a commit ffa22f6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/query/query.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export function createQuery(instanceOptions?: Configuration): Query {
167167
// For the refetching event, we want to immediately return if there's
168168
// a pending resolver.
169169
if (event === 'refetching' && value !== undefined) {
170-
emit(key, event, value.item)
170+
queueMicrotask(() => emit(key, event, value.item))
171171
}
172172

173173
return function () {
@@ -426,7 +426,7 @@ export function createQuery(instanceOptions?: Configuration): Query {
426426

427427
// Adds the resolver to the cache.
428428
resolversCache.set(key, { item: result, controller })
429-
emit(key, 'refetching', result)
429+
queueMicrotask(() => emit(key, 'refetching', result))
430430

431431
// The promise executor runs synchronously,
432432
// so trigger is guaranteed to be defined here.

0 commit comments

Comments
 (0)