Skip to content

Documentation / @finchart/react / Plugin

Function: Plugin() ​

Plugin<TApi>(__namedParameters): null

Defined in: react/src/components/plugin.tsx:47

A plugin install as a child — the declarative lane's way to put a tool on the chart and hand its api up, where usePlugin would need a component of its own just to call the hook inside the container:

tsx
<Plugin install={(plot) => plot.use(paneMaximize({ gestures: true }))} />
<ChartPane>
  <Plugin<DrawingToolsApi> install={(plot, pane) => pane.use(drawingTools({ plot }))} onApi={setTools} />
</ChartPane>

With a useState setter as onApi and an inline install, name the api type (<Plugin<DrawingToolsApi> …>): TypeScript reads install's inline parameters after it has checked the setter, so it can't infer the type from install there. An install declared with typed parameters, or an inline onApi, needs nothing.

Type Parameters ​

TApi ​

TApi extends object

Parameters ​

__namedParameters ​

PluginProps<TApi>

Returns ​

null