Coder Social home page Coder Social logo

Comments (6)

NetrushGarrett avatar NetrushGarrett commented on August 11, 2024

I was able to get around this by unmounting and remounting the component every time I change the value instead of relying on prop change to update, That way when it does resize there's no prevProps for it to look at.

from react-gauge-chart.

aaroncrawford avatar aaroncrawford commented on August 11, 2024

Receiving this as well. Had to put extra logic in to ensure that the gauge never received zero data before my state was changed with it's final set of data.

from react-gauge-chart.

dominicboston avatar dominicboston commented on August 11, 2024

I'm having the same issue here, but it is triggered by scrolling down to the bottom of the page on mobile. I also made a sandbox to confirm this with the resize reset. Click the button then resize the window. Can we turn this issue report into an official bug?
video of problem https://dab-online.co.uk/RPReplay_Final1606780028.MP4
https://codesandbox.io/s/reactgaugeresize-wwbct?file=/src/App.js

from react-gauge-chart.

dominicboston avatar dominicboston commented on August 11, 2024

Thanks for merge - this issue can now be closed.

from react-gauge-chart.

jeff1evesque avatar jeff1evesque commented on August 11, 2024

I was able to keep using react-gauge-chart at version 0.3.0, and followed an above recommendation:

(base) jeff1evesque@AlienWareMacBook supercode % git diff jsx
diff --git a/jsx/import/xyz/flashy-popsicles.jsx b/jsx/import/xyz/flashy-popsicles.jsx
index 12b62c2..e9bfa63 100644
--- a/jsx/import/xyz/flashy-popsicles.jsx
+++ b/jsx/import/xyz/flashy-popsicles.jsx
@@ -110,6 +110,21 @@ class Chart extends Component {
             colors: colors,
             arcs_length: arcs_length
         }
+
+        this.resize = this.resize.bind(this);
+    }
+
+    resize() {
+        if (
+            'percent' in this.props
+            && checkValidFloat(this.props.percent)
+        ) {
+            this.setState({ percent: this.props.percent });
+        }
+    }
+
+    componentDidMount() {
+        window.addEventListener('resize', this.resize);
     }
 
     componentDidUpdate(prevProps, prevState) {
(base) jeff1evesque@AlienWareMacBook supercode % 

from react-gauge-chart.

jeff1evesque avatar jeff1evesque commented on August 11, 2024

My workaround is still a bit glitchy, since its not very smooth between transition of the needle being forced to a (re)render on window resize.

from react-gauge-chart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.