From 94cd8d35af7ba5ca1f3efabde83cbd85d70a78ce Mon Sep 17 00:00:00 2001 From: Cody Bennett Date: Mon, 13 Jan 2025 13:24:26 -0600 Subject: [PATCH] feat: flushSync --- src/index.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/index.tsx b/src/index.tsx index 729f696..1df0cac 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -103,6 +103,13 @@ reconciler.injectIntoDevTools({ rendererPackageName: 'react-nil', }) +/** + * Force React to flush any updates inside the provided callback synchronously and immediately. + */ +export function flushSync(fn: () => R): R { + return reconciler.flushSync(fn, undefined) +} + const container: HostContainer = { head: null } const root = reconciler.createContainer(container, ConcurrentRoot, null, false, null, '', console.error, null)