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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classContext.ConsumerBuilder<ST extends @Nullable Object>A Builder for the Consumer component.static interfaceContext.ConsumerRenderFunction<T extends @Nullable Object>Interface used to type the render function input.static final classContext.ProviderBuilder<ST extends @Nullable Object>A Builder for the Provider component. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconsumer()Create a builder for the Consumer component.provide(@Nullable T value, @Nullable Renderable @Nullable ... children) Create a provider component that provides specified value to specified children.provider()Create a builder for the Provider component.
-
Constructor Details
-
Context
public Context()
-
-
Method Details
-
provider
Create a builder for the Provider component.- Returns:
- a builder for the Provider component.
-
provide
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
Create a builder for the Consumer component.- Returns:
- a builder for the Consumer component.
-