Skip to content

Commit

Permalink
fix: fix problem loading events in tables when displayed for the firs…
Browse files Browse the repository at this point in the history
…t time (#709)

Co-authored-by: Jpabon <jpabonb@bidda.net>
  • Loading branch information
dorlanpabon and Jpabon committed Jul 20, 2023
1 parent 45a4801 commit b2ce2c3
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/components/GoogleChartEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface ListenToEventsArgs {
}

export class GoogleChartEvents extends React.Component<Props> {
propsFromContext: ReactGoogleChartProps | null;
shouldComponentUpdate() {
return false;
}
Expand Down Expand Up @@ -52,19 +53,31 @@ export class GoogleChartEvents extends React.Component<Props> {
);
}
}

componentDidMount() {
const { google, googleChartWrapper } = this.props;

this.listenToEvents({
chartEvents: this.propsFromContext?.chartEvents || null,
google,
googleChartWrapper,
});
}

render() {
const { google, googleChartWrapper } = this.props;
return (
<ContextConsumer
render={(propsFromContext) => {
this.listenToEvents({
chartEvents: propsFromContext.chartEvents || null,
google,
googleChartWrapper,
});
this.propsFromContext = propsFromContext;
return null;
}}
/>
);
}

constructor(props: Props) {
super(props);
this.propsFromContext = null;
}
}

1 comment on commit b2ce2c3

@vercel
Copy link

@vercel vercel bot commented on b2ce2c3 Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.