contextType property
The contextType property lets you consume the nearest current value of that context's Provider using context.
contextType is assigned as Context.reactDartContext
after being created by createContext
.
Example:
Context MyContext = createContext('test');
class MyClass extends UiComponent2 {
@override
final contextType = MyContext.reactDartContext;
render() {
return Dom.span()(
'${this.context}', // Outputs: 'test'
);
}
}
Implementation
@override
react.Context? get contextType => super.contextType;