Skip to content

Commit 1a1b404

Browse files
author
Madeline Trotter
committed
Refactor concurrent api to match the underlying React api
1 parent 1ad905a commit 1a1b404

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/React/Basic/DOM/Concurrent.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
const ReactDOM = require("react-dom");
44
const createRoot = ReactDOM.createRoot || ReactDOM.unstable_createRoot;
5+
const createBlockingRoot =
6+
ReactDOM.createBlockingRoot || ReactDOM.unstable_createBlockingRoot;
57

6-
exports.renderConcurrentMode = (jsx) => (element) => () =>
7-
createRoot(element).render(jsx);
8+
exports.createRoot = (element) => () => createRoot(element);
9+
10+
exports.createBlockingRoot = (element) => () => createBlockingRoot(element);
11+
12+
exports.renderRoot = (root) => (jsx) => () => root.render(jsx);

src/React/Basic/DOM/Concurrent.purs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import Effect (Effect)
77
import React.Basic (JSX)
88
import Web.DOM (Element)
99

10-
-- Alternative to `render` which enables React's concurrent mode.
11-
-- This is an unstable and experimental feature. See the React docs for more info.
12-
foreign import renderConcurrentMode :: JSX -> Element -> Effect Unit
10+
foreign import data ReactRoot :: Type
11+
12+
foreign import createRoot :: Element -> Effect ReactRoot
13+
14+
foreign import createBlockingRoot :: Element -> Effect ReactRoot
15+
16+
foreign import renderRoot :: ReactRoot -> JSX -> Effect Unit

0 commit comments

Comments
 (0)