Method UseContext
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
UseContext<T>(ComponentContext<T>)
Reads the value of the given context from the nearest Provider. Returns the context's default value when no Provider is present.
public static T UseContext<T>(ComponentContext<T> context)
Parameters
contextComponentContext<T>Context object to read. Must not be null.
Returns
- T
Provided value when an ancestor Provider is present, otherwise
context.DefaultValue.
Type Parameters
TContext value type.
Remarks
Always reflects the nearest enclosing Provider at the moment Render() runs, including after an isolated re-render (state update / context change), not a value pinned at first render.