@JsType(isNative=true,
namespace="<global>")
public class ReactDOM
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
batchedUpdates(react4j.core.Procedure action)
Batch all state updates within the action.
|
static react4j.core.ReactNode |
createElement(java.lang.String type)
Create and return a new ReactElement of the given type.
|
static <P extends HtmlGlobalFields> |
createElement(java.lang.String type,
P props)
Create and return a new ReactElement of the given type.
|
static <P extends HtmlGlobalFields> |
createElement(java.lang.String type,
P props,
react4j.core.ReactNode... children)
Create and return a new ReactElement of the given type with specified children.
|
static ReactPortal |
createPortal(react4j.core.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 java.lang.Object |
render(react4j.core.ReactNode node,
elemental2.dom.Element container)
Render a React element into the DOM in the supplied container.
|
static java.lang.Object |
render(react4j.core.ReactNode node,
elemental2.dom.Element container,
react4j.core.Procedure 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.
|
public static ReactPortal createPortal(@Nonnull react4j.core.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.core.ReactNode node, @Nonnull elemental2.dom.Element container, @Nullable react4j.core.Procedure 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.core.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, Procedure)
public static boolean unmountComponentAtNode(@Nonnull elemental2.dom.Element container)
container
- the DOM container containing the react component to unmount@Nonnull @JsOverlay public static react4j.core.ReactNode createElement(@Nonnull java.lang.String type)
type
- A HTML tag name (eg. 'div', 'span', etc)@Nonnull @JsMethod(namespace="React") public static <P extends HtmlGlobalFields> react4j.core.ReactNode createElement(@Nonnull java.lang.String type, @Nullable P props)
P
- The type of the props. It should match the associated tag name.type
- A HTML tag name (eg. 'div', 'span', etc)props
- The props to pass to the element.@Nonnull @JsMethod(namespace="React") public static <P extends HtmlGlobalFields> react4j.core.ReactNode createElement(@Nonnull java.lang.String type, @Nullable P props, @Nullable react4j.core.ReactNode... children)
P
- The type of the props. It should match the associated tag name.type
- A HTML tag name (eg. 'div', 'span', etc)props
- The props to pass to the element.children
- The child elements.@JsOverlay public static void batchedUpdates(@Nonnull react4j.core.Procedure action)
action
- the action where all state updates are batched.