Class Context<T extends @Nullable Object>

java.lang.Object
react4j.Context<T>

@JsType(isNative=true, namespace="<global>", name="Object") public final class Context<T extends @Nullable Object> extends Object
Context is designed to share data that can be considered "global" for a tree of views. In a typical React application, data is passed top-down (parent to child) via inputs, but this can be cumbersome for certain types of inputs (e.g. locale preference, UI theme) that are required by many views within an application. Context provides a way to share values like this between views without having to explicitly pass a input through every level of the tree.
  • Constructor Details

    • Context

      public Context()
  • Method Details

    • provider

      @JsOverlay public Context.ProviderBuilder<T> provider()
      Create a builder for the Provider component.
      Returns:
      a builder for the Provider component.
    • provide

      @JsOverlay public ReactNode provide(@Nullable T value, @Nullable Renderable @Nullable ... children)
      Create a provider component that provides specified value to specified children.
      Parameters:
      value - the value to provider to children.
      children - the child elements.
      Returns:
      the element.
    • consumer

      @JsOverlay public Context.ConsumerBuilder<T> consumer()
      Create a builder for the Consumer component.
      Returns:
      a builder for the Consumer component.