What are Roact Portals and when to use them
masterPortals are a special type of component that allow you to render Roact-managed objects into a separate, non-Roact Instance (a target).
This is useful for rendering UI elements that need to exist outside of the current Roact tree hierarchy, such as full-screen modal dialogs that should reside in PlayerGui even if the component triggering them is deep within a different UI hierarchy.
Warning: Portals should only be used to target objects that are not already managed by Roact. Targeting a Roact-managed Instance with a Portal can lead to unexpected behavior or conflicts in instance management.
-- Example of a Portal targeting Workspace
local function PartInWorkspace(props)
return Roact.createElement(Roact.Portal, {
target = Workspace
}, {
SomePart = Roact.createElement("Part", {
Anchored = true
})
})
end