How to use React.createPortal
in drag-drop components?
#514
cruxcode
started this conversation in
Guides: Atri Framework Reference
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Please do not use
React.createPortal
directly while creating a drag-drop component. TheReact.createPortal
function has been wrapped insidecreatePortal
function from@atrilabs/core
. ThiscreatePortal
function takes thewindow
object as an argument. To get thiswindow
object, use theuseGlobalContext
custom hook from "@atrilabs/core".This window object is actually theiframe.contentWindow
inside the editor while the window object is the actual window in the generated app. The portals render immediately inside the editor while they render only afteruseEffect
hooks have run in the generated app. This difference in behavior is to avoid hydration mismatch error while usingReact.createPortal
in server side rendering.Beta Was this translation helpful? Give feedback.
All reactions