From f104e09f3f1b9a6508f94b18d19a9c246a25fb35 Mon Sep 17 00:00:00 2001 From: Cameron DeCoster Date: Thu, 18 Jun 2026 12:15:01 -0600 Subject: [PATCH] fix: Update type to reflect forwardRef wrapped component --- src/factory.d.ts | 10 +++++++++- src/index.d.ts | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/factory.d.ts b/src/factory.d.ts index f8d0dce..34e75ea 100644 --- a/src/factory.d.ts +++ b/src/factory.d.ts @@ -71,7 +71,15 @@ export interface PlotParams { * Build a Plot component bound to a specific plotly.js instance. Use this * when shipping a custom plotly.js bundle (e.g. the basic, cartesian, or * a custom partial bundle) instead of the full library. + * + * The returned component is `forwardRef`-wrapped, so consumers can attach a + * ref to access the underlying graph div (e.g. for `Plotly.animate` calls + * outside the React update cycle). */ -declare function createPlotlyComponent(Plotly: unknown): React.ComponentType; +declare function createPlotlyComponent( + Plotly: unknown +): React.ForwardRefExoticComponent< + PlotParams & React.RefAttributes +>; export default createPlotlyComponent; diff --git a/src/index.d.ts b/src/index.d.ts index 8ad7fdc..ff3f897 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,7 +1,9 @@ import type React from 'react'; import type {PlotParams} from './factory'; -declare const Plot: React.ComponentType; +declare const Plot: React.ForwardRefExoticComponent< + PlotParams & React.RefAttributes +>; export default Plot; export {Figure, FigureCallback, EventCallback, PlotParams} from './factory';