From b2ce2c330c4951f6735e44e943c3556a8651c58a Mon Sep 17 00:00:00 2001 From: dorlanpabon Date: Thu, 20 Jul 2023 10:41:07 -0500 Subject: [PATCH] fix: fix problem loading events in tables when displayed for the first time (#709) Co-authored-by: Jpabon --- src/components/GoogleChartEvents.tsx | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) 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; + } }