Triggering useEffect() to on panel refresh

Hey All, I have what I hope is a simple question.

I have a custom panel plugin making a REST call using useEffect().

As expected, on first render, everything works, but I am struggling on how to get the dashboard refresh to make a new REST call.

For example, setting the page dashboard refresh to 30s, I see the console log I have fire, but how do I correctly get useEffect() to run to get an update?

Please note: I currently have a dirty hack that increments a counter on a timer, which of course ignores the grafana refresh period.

Gist of the code here:

I have created a new plugin that gets the public IP address via REST call.

It uses the same approach that I was having an issue with, but this is a clearer PoC:

Just to close this off, I ended up refactoring to using the same approach as the clock panel:

export class ClockPanel extends PureComponent<Props, State> {
  timerID?: any;
  state = { now: this.getTZ(), timezone: '' };

  componentDidMount() {
    this.timerID = setInterval(
      () => this.tick(),
      1000 // 1 second
    );
  }

  componentWillUnmount() {
    clearInterval(this.timerID);
  }

  tick() {
    const { timezone } = this.props.options;
    this.setState({ now: this.getTZ(timezone) });
  }

  [...]