diff --git a/src/components/GoogleChartEvents.tsx b/src/components/GoogleChartEvents.tsx index 664df462..25a1404f 100644 --- a/src/components/GoogleChartEvents.tsx +++ b/src/components/GoogleChartEvents.tsx @@ -24,6 +24,7 @@ export interface ListenToEventsArgs { } export class GoogleChartEvents extends React.Component { + propsFromContext: ReactGoogleChartProps | null; shouldComponentUpdate() { return false; } @@ -52,19 +53,31 @@ export class GoogleChartEvents extends React.Component { ); } } + + componentDidMount() { + const { google, googleChartWrapper } = this.props; + + this.listenToEvents({ + chartEvents: this.propsFromContext?.chartEvents || null, + google, + googleChartWrapper, + }); + } + render() { const { google, googleChartWrapper } = this.props; return ( { - this.listenToEvents({ - chartEvents: propsFromContext.chartEvents || null, - google, - googleChartWrapper, - }); + this.propsFromContext = propsFromContext; return null; }} /> ); } + + constructor(props: Props) { + super(props); + this.propsFromContext = null; + } }