Package react4j

Class Context<T>

java.lang.Object
react4j.Context<T>

@JsType(isNative=true, namespace="<global>", name="Object") public final class Context<T> 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

  • Method Details

    • provider

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

      @JsOverlay @Nonnull public ReactNode provide(@Nullable T value, ReactNode... 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 @Nonnull public Context.ConsumerBuilder<T> consumer()
      Create a builder for the Consumer component.
      Returns:
      a builder for the Consumer component.