Package react4j.dom

Class ReactDOM

java.lang.Object
react4j.dom.ReactDOM

@JsType(isNative=true, namespace="<global>") public class ReactDOM extends Object
Core interface into React DOM library.
  • Method Details

    • createRoot

      @JsOverlay @Nonnull public static ReactRoot createRoot(@Nonnull akasha.Element container)
    • 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

      public static boolean unmountComponentAtNode(@Nonnull akasha.Element container)
      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

      @JsOverlay public static void batchedUpdates(@Nonnull ReactDOM.BatchedUpdatesFn action)
      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

      @JsOverlay public static void registerBatchedArezTaskInterceptor()
      Register an task interceptor on the current Arez context that ensures any view updates are batched.
    • registerBatchedArezTaskInterceptor

      @JsOverlay public static void registerBatchedArezTaskInterceptor(@Nonnull ArezContext context)
      Register an task interceptor that ensures any view updates are batched.
      Parameters:
      context - the context to add interceptor to.