Skip to content

Commit

Permalink
fix: run flushSync in microtask
Browse files Browse the repository at this point in the history
  • Loading branch information
Ni55aN committed Oct 24, 2023
1 parent 5a92d81 commit fa2ba02
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,7 @@ export function syncFlush() {
return {
apply(f: () => void) {
if (ready.current) {
try {
flushSync(f)
} catch (error) {
const message = error ? (error as Error).message : null

if (message && (
message.includes('flushSync was called from inside a lifecycle method')
|| message.includes('React error #187')
)) {
f()
return
}
throw error
}
queueMicrotask(() => flushSync(f))
} else {
f()
}
Expand Down

0 comments on commit fa2ba02

Please sign in to comment.