Context<TValue> class

The return type of createContext, Wraps ReactContext for use in Dart. Allows access to Provider and Consumer Components.

Should not be instantiated without using createContext

Example:

Context MyContext = createContext();
...
class MyComponent extends UiComponent2<...> {
  render() {
    return (MyContext.Provider()..value = 'new context value')(
      MyContext.Consumer()(
        (value) {
          return Dom.span()(
            '$value', // Outputs: 'new context value'
          );
        }
      );
    );
  }
}

Learn more at: https://react.dev/learn/passing-data-deeply-with-context

Constructors

Context(UiFactory<ProviderProps<TValue>> Provider, UiFactory<ConsumerProps<TValue>> Consumer, Context<TValue> reactDartContext)
Context.fromJsContext(ReactContext jsContext)
factory
Context.fromReactDartContext(Context<TValue> reactDartContext)
factory

Properties

Consumer UiFactory<ConsumerProps<TValue>>
A React component that subscribes to context changes.
final
hashCode int
The hash code for this object.
no setterinherited
jsThis ReactContext
The react.js version of this context.
no setter
Provider UiFactory<ProviderProps<TValue>>
Every Context object comes with a Provider component that allows consuming components to subscribe to context changes.
final
reactDartContext → Context<TValue>
The react.dart version of this context.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited