File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,7 @@ export function unmount(node) {
19
19
export function createPortal ( jsx ) {
20
20
return ( node ) => ReactDOM . createPortal ( jsx , node ) ;
21
21
}
22
+
23
+ export function flushSync ( callback ) {
24
+ return ( ) => ReactDOM . flushSync ( callback ) ;
25
+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ module React.Basic.DOM
13
13
, unmount
14
14
, createPortal
15
15
, text
16
+ , flushSync
16
17
, module Generated
17
18
) where
18
19
@@ -100,4 +101,15 @@ foreign import createPortal :: JSX -> Element -> JSX
100
101
101
102
-- | Create a text node.
102
103
text :: String -> JSX
103
- text = unsafeCoerce
104
+ text = unsafeCoerce
105
+
106
+ -- | `flushSync` lets you force React to flush any updates inside the provided
107
+ -- | callback synchronously. This ensures that the DOM is updated immediately.
108
+ -- |
109
+ -- | ```purs
110
+ -- | let
111
+ -- | handleNewChatMessage msg = do
112
+ -- | flushSync (setMessages (_ <> [msg]))
113
+ -- | scrollToLastMessage
114
+ -- | ```
115
+ foreign import flushSync :: forall a . Effect a -> Effect a
You can’t perform that action at this time.
0 commit comments