LGSInnovations / react-sigplot

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

HrefLayer url based on React state does not update/make HTTP call #19

Open geeklisted opened 3 years ago

geeklisted commented 3 years ago

When SigPlot uses HrefLayer with a url based on a React state variable, when the variable is first set, SigPlot loads the given URL. On subsequent changes, an HTTP call to reload the new file is never made.

mrecachinas commented 3 years ago

Thanks for the issue. This is interesting. I'm not seeing the behavior you're indicating (i.e., only the initial HTTP request is being sent, but subsequent requests are not), but I am seeing some weirdness. Here's my simple App.js:

import React, { useState } from 'react';
import {SigPlot, HrefLayer} from 'react-sigplot';

function App() {
  const [href, setHref] = useState("http://sigplot.lgsinnovations.com/dat/penny.prm");
  return (
    <div className="App">
      <SigPlot height={300} width={900}>
        <HrefLayer href={href} />
      </SigPlot>
      <ul>
        <li onClick={() => setHref("http://sigplot.lgsinnovations.com/dat/penny.prm")}>
          Penny.prm
        </li>
        <li onClick={() => setHref("http://sigplot.lgsinnovations.com/dat/sin.tmp")}>
          Sin.tmp
        </li>
      </ul>
    </div>
  );
}

export default App;

Also, here is my package.json:

{
  "name": "sigplot-href-test",
  "version": "0.1.0",
  "dependencies": {
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.3",
    "react-sigplot": "^0.1.11"
  },
  "scripts": {
    "start": "react-scripts start"
  },
  "eslintConfig": {
    "extends": "react-app"
  }
}

While I am seeing network requests for each state change:

image

Here's what the plot looks like afterward:

image

This is likely due to not handling this.layer properly. I'll take a look.

mrecachinas commented 3 years ago

20 should address this. Please try using the master branch on https://github.com/spectriclabs/react-sigplot.git and let me know if that fixes the issue you're observing.

geeklisted commented 3 years ago

Great, will take a look and report back. Thank you.

mrecachinas commented 3 years ago

@geeklisted Let us know if this is still an issue.