Documentation / @ripl/vue-charts / useRiplContext
Function: useRiplContext() ​
useRiplContext():
ShallowRef<Context<Element,Record<string,unknown>> |undefined>
Defined in: vue/src/compositions/index.ts:42
Returns the rendering context provided by the nearest context component.
The context is created during that component's setup(), so this already resolves in a descendant's own setup() — no watching required. It is undefined only outside a context component, or during server rendering.
Returns ​
ShallowRef<Context<Element, Record<string, unknown>> | undefined>
The context, or undefined when there is none.
Example ​
ts
const context = useRiplContext();
function exportPNG() {
return context.value?.export().toURL();
}