LGSInnovations / react-sigplot

React wrapper for SigPlot.js
https://sigplot.lgsinnovations.com
Apache License 2.0
4 stars 10 forks source link

Investigate whether `plot.deoverlay()` is necessary #5

Open mrecachinas opened 5 years ago

mrecachinas commented 5 years ago

In src/hreflayer.js and src/websocketlayer.js,

  componentDidMount() {
    const { href, onload, options } = this.props;
    this.plot.deoverlay(); // <----------------
    this.layer = this.plot.overlay_href(href, onload, options);
  }

  componentWillReceiveProps(nextProps) {
    const {
      href: oldHref,
      options: oldOptions,
    } = this.props;

    const {
      href: newHref,
      onload: newOnload,
      options: newOptions,
    } = nextProps;

    // we only care if `href` or `options` changes
    if (newHref !== oldHref) {
      this.plot.deoverlay(); // <----------------
      this.plot.overlay_href(newHref, newOnload, newOptions);
    } else if (newOptions !== oldOptions) {
      this.plot.change_settings(newOptions);
    } else {
      return;
    }
  }

src/websocketlayer.js looks roughly the same.