Git Product home page Git Product logo

Comments (6)

vydimitrov avatar vydimitrov commented on July 17, 2024 3

Your problem is that props.durationInSeconds is a string, it should number

      <TimerField
        // TODO: how to have this working?
        durationInSeconds="4" <----- this should be number, like  durationInSeconds={4}
      />

I am not sure why you don't see warnings from prop-types but duration should be a number. Also colors props is not correctly set, you are missing the transition duration next to each color:

 <CountdownCircleTimer
      isPlaying
      duration={props.durationInSeconds}
      colors={[["#00FF00"], ["#FF0000"]]} <----- this is wrong value for colors
      onComplete={() => [true, 1000]}
    >

Below is the correct way to set the colors, you can adjust the numbers
colors={[["#00FF00", 0.5], ["#FF0000", 0.5]]}

Please review the list of props, their types and how you can use them.

from react-countdown-circle-timer.

vydimitrov avatar vydimitrov commented on July 17, 2024 1

I am closing this one. Let me know if something is not clear.

from react-countdown-circle-timer.

ropinheiro avatar ropinheiro commented on July 17, 2024 1

About the colors, it was just a demo, I have that part a bit more complicated to force some nuances (and it is working), but thank you for the additional correction detail!

from react-countdown-circle-timer.

vydimitrov avatar vydimitrov commented on July 17, 2024

Hey, it really doesn't matter how to you pass the duration to the component, as long as it is a number it is going to work. However, I suspect that the colors you are feeding the component is not correct.

Can you share a bit more of your code or even better create a Codesandbox reproducing the issue and I will take a look on it?

from react-countdown-circle-timer.

ropinheiro avatar ropinheiro commented on July 17, 2024

Sure, here is it:
https://codesandbox.io/s/frosty-https-p0c7y

As you can see, it starts with a countdown timer starting at 4, as defined here:

image

When it reaches zero, because onComplete is set to true, it tries to start a second cycle and raises exception:

image

If you remove the props. here, making the duration now being feed by the durationInSeconds local constant:

image

You will now see the countdown timer starting at 20, doing a full circle then starting again, endlessly.

For any reason, passing the duration as a prop causes this problem. Not sure why. I really need this construction, as I have the Timer under some other covering components and the duration must be provided by prop.

from react-countdown-circle-timer.

ropinheiro avatar ropinheiro commented on July 17, 2024

OMG, that was it. The '20' instead of {20}. I really don't understand how could I miss that after looking hundreds of times to the code :( Thank you very much!

from react-countdown-circle-timer.

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.