ndresx / react-countdown

A customizable countdown component for React.
MIT License
746 stars 69 forks source link

Cannot reset countdown with key #235

Closed xuanhung1509 closed 1 year ago

xuanhung1509 commented 1 year ago

Hi everyone,

However, it works for the date prop:

  const handleClaimRewardClick = (): void => {
    setIsCompleted(false);
    setDate(prev => prev + 1); // this works, but I don't want to change the date
    alert('Rewards claimed!');
  };
ndresx commented 1 year ago

Hi, ok, the key approach is good, but the date needs to be an absolute date time in the future, which means you would also have to adjust it in any case when some time has passed. It could then also be used as the key.

ndresx commented 1 year ago

I'm closing this. Please feel free to re-open or create a new issue if you still encounter this problem!