Class ReactDOM
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface for performing an action inside batch.static interface
Interface for performing an action on render complete. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Batch all state updates within the action.static ReactPortal
createPortal
(ReactNode children, akasha.Element container) Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.static ReactRoot
createRoot
(akasha.Element container) static void
Register an task interceptor on the current Arez context that ensures any view updates are batched.static void
Register an task interceptor that ensures any view updates are batched.static Object
Render a React element into the DOM in the supplied container.static Object
render
(ReactNode node, akasha.Element container, ReactDOM.RenderCallbackFn onUpdate) Render a React element into the DOM in the supplied container.static boolean
unmountComponentAtNode
(akasha.Element container) Remove a mounted React component from the DOM and clean up its event handlers and state.
-
Method Details
-
createRoot
-
createPortal
public static ReactPortal createPortal(@Nonnull ReactNode children, @Nonnull akasha.Element container) Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.Even though a portal can be anywhere in the DOM tree, it behaves like a normal React child in every other way. Features like context work exactly the same regardless of whether the child is a portal, as the portal still exists in the React tree regardless of position in the DOM tree.
This includes event bubbling. An event fired from inside a portal will propagate to ancestors in the containing React tree, even if those elements are not ancestors in the DOM tree.
- Parameters:
children
- the react node to render.container
- the DOM element to render into.- Returns:
- the new portal.
-
render
@Nullable @JsOverlay public static Object render(@Nonnull ReactNode node, @Nonnull akasha.Element container, @Nullable ReactDOM.RenderCallbackFn onUpdate) Render a React element into the DOM in the supplied container.If the React element was previously rendered into container, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React element.
If the optional callback is provided, it will be executed after the component is rendered or updated.
- Parameters:
node
- the react node to render.container
- the DOM element to render into.onUpdate
- the callback invoked when rendering is complete.- Returns:
- a reference to the created React Component, DOM Node, Portal or null (stateless components).
-
render
@Nullable @JsOverlay public static Object render(@Nonnull ReactNode node, @Nonnull akasha.Element container) Render a React element into the DOM in the supplied container.If the React element was previously rendered into container, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React element.
- Parameters:
node
- the react node to render.container
- the DOM element to render into.- Returns:
- a reference to the created React Component, DOM Node, Portal or null (stateless components).
- See Also:
-
unmountComponentAtNode
Remove a mounted React component from the DOM and clean up its event handlers and state. If no component was mounted in the container, calling this function does nothing.- Parameters:
container
- the DOM container containing the react component to unmount- Returns:
- true if a component was unmounted and false if there was no component to unmount.
-
batchedUpdates
Batch all state updates within the action. This is currently an unstable API within the React 16, mostly because it is only useful when called outside an event handler (i.e. from network code) and because it is likely to be enabled by default in a later version of React.- Parameters:
action
- the action where all state updates are batched.
-
registerBatchedArezTaskInterceptor
Register an task interceptor on the current Arez context that ensures any view updates are batched. -
registerBatchedArezTaskInterceptor
Register an task interceptor that ensures any view updates are batched.- Parameters:
context
- the context to add interceptor to.
-