diff --git a/src/React/Basic/DOM.js b/src/React/Basic/DOM.js index de26467..257f887 100644 --- a/src/React/Basic/DOM.js +++ b/src/React/Basic/DOM.js @@ -19,3 +19,7 @@ export function unmount(node) { export function createPortal(jsx) { return (node) => ReactDOM.createPortal(jsx, node); } + +export function flushSync(callback) { + return () => ReactDOM.flushSync(callback); +} diff --git a/src/React/Basic/DOM.purs b/src/React/Basic/DOM.purs index fc20ffb..0acb058 100644 --- a/src/React/Basic/DOM.purs +++ b/src/React/Basic/DOM.purs @@ -13,6 +13,7 @@ module React.Basic.DOM , unmount , createPortal , text + , flushSync , module Generated ) where @@ -100,4 +101,15 @@ foreign import createPortal :: JSX -> Element -> JSX -- | Create a text node. text :: String -> JSX -text = unsafeCoerce \ No newline at end of file +text = unsafeCoerce + +-- | `flushSync` lets you force React to flush any updates inside the provided +-- | callback synchronously. This ensures that the DOM is updated immediately. +-- | +-- | ```purs +-- | let +-- | handleNewChatMessage msg = do +-- | flushSync (setMessages (_ <> [msg])) +-- | scrollToLastMessage +-- | ``` +foreign import flushSync :: forall a. Effect a -> Effect a pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy