@JsType(isNative=true,
namespace="<global>")
public class ReactDOM
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
ReactDOM.BatchedUpdatesFn
Interface for performing an action inside batch.
|
static interface |
ReactDOM.RenderCallbackFn
Interface for performing an action on render complete.
|
Modifier and Type | Method and Description |
---|---|
static void |
batchedUpdates(ReactDOM.BatchedUpdatesFn action)
Batch all state updates within the action.
|
static ReactPortal |
createPortal(react4j.ReactNode children,
elemental2.dom.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(elemental2.dom.Element container) |
static void |
registerBatchedArezTaskInterceptor()
Register an task interceptor on the current Arez context that ensures any view updates are batched.
|
static void |
registerBatchedArezTaskInterceptor(arez.ArezContext context)
Register an task interceptor that ensures any view updates are batched.
|
static java.lang.Object |
render(react4j.ReactNode node,
elemental2.dom.Element container)
Render a React element into the DOM in the supplied container.
|
static java.lang.Object |
render(react4j.ReactNode node,
elemental2.dom.Element container,
ReactDOM.RenderCallbackFn onUpdate)
Render a React element into the DOM in the supplied container.
|
static boolean |
unmountComponentAtNode(elemental2.dom.Element container)
Remove a mounted React component from the DOM and clean up its event handlers and state.
|
@JsOverlay @Nonnull public static ReactRoot createRoot(@Nonnull elemental2.dom.Element container)
public static ReactPortal createPortal(@Nonnull react4j.ReactNode children, @Nonnull elemental2.dom.Element container)
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.
children
- the react node to render.container
- the DOM element to render into.@Nullable @JsOverlay public static java.lang.Object render(@Nonnull react4j.ReactNode node, @Nonnull elemental2.dom.Element container, @Nullable ReactDOM.RenderCallbackFn onUpdate)
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.
node
- the react node to render.container
- the DOM element to render into.onUpdate
- the callback invoked when rendering is complete.@Nullable @JsOverlay public static java.lang.Object render(@Nonnull react4j.ReactNode node, @Nonnull elemental2.dom.Element 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.
node
- the react node to render.container
- the DOM element to render into.render(ReactNode, Element, RenderCallbackFn)
public static boolean unmountComponentAtNode(@Nonnull elemental2.dom.Element container)
container
- the DOM container containing the react component to unmount@JsOverlay public static void batchedUpdates(@Nonnull ReactDOM.BatchedUpdatesFn action)
action
- the action where all state updates are batched.@JsOverlay public static void registerBatchedArezTaskInterceptor()
@JsOverlay public static void registerBatchedArezTaskInterceptor(@Nonnull arez.ArezContext context)
context
- the context to add interceptor to.