-
Notifications
You must be signed in to change notification settings - Fork 15
createRoot (replacing render) #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
status: accepted
This issue is now ready to be implemented via a PR.
type: enhancement
A new feature or addition.
Comments
There is this (different lib): https://pursuit.purescript.org/packages/purescript-react-basic-dom/4.2.0/docs/React.Basic.DOM.Concurrent#v:createRoot |
"use strict"
import ReactDOMClient from "react-dom/client"
export const createRoot = container => () => ReactDOMClient.createRoot(container)
export const render = root => reactElement => () => root.render(reactElement) import Effect (Effect)
import Prelude
import React (ReactElement)
import Web.DOM.Element (Element)
foreign import data Root :: Type
foreign import createRoot :: Element -> Effect Root
foreign import render :: Root -> ReactElement -> Effect Unit import Data.Maybe (fromJust)
import Partial.Unsafe (unsafePartial)
import React (createLeafElement)
import Web.DOM.NonElementParentNode (getElementById)
import Web.HTML (window)
import Web.HTML.HTMLDocument (toNonElementParentNode)
import Web.HTML.Window (document)
main :: Effect Unit
main = do
doc <- window >>= document
container <- getElementById "container" $ toNonElementParentNode doc
root <- createRoot $ unsafePartial $ fromJust container
render root $ createLeafElement appClass props <div id="container"></div>
<script src="index.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
status: accepted
This issue is now ready to be implemented via a PR.
type: enhancement
A new feature or addition.
React 18 was released. It encourages a switch from
render
tocreateRoot
to benefit from the new implementation.The text was updated successfully, but these errors were encountered: