reactjs-countdown-hook
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -137,3 +137,3 @@ import { useState, useEffect } from 'react'; | ||
intervalId = setInterval(function () { | ||
if (counter >= 1) { | ||
if (counter.count >= 1) { | ||
setCounter(function (counter) { | ||
@@ -152,6 +152,6 @@ return _objectSpread2(_objectSpread2({}, counter), {}, { | ||
var secondCounter = counter % 60; | ||
var minuteCounter = Math.floor(counter % 3600 / 60); | ||
var hourCounter = Math.floor(counter % (3600 * 24) / 3600); | ||
var daysCounter = Math.floor(counter / (3600 * 24)); | ||
var secondCounter = counter.count % 60; | ||
var minuteCounter = Math.floor(counter.count % 3600 / 60); | ||
var hourCounter = Math.floor(counter.count % (3600 * 24) / 3600); | ||
var daysCounter = Math.floor(counter.count / (3600 * 24)); | ||
var computedSecond = String(secondCounter).length === 1 ? "0".concat(secondCounter) : secondCounter; | ||
@@ -175,3 +175,3 @@ var computedMinute = String(minuteCounter).length === 1 ? "0".concat(minuteCounter) : minuteCounter; | ||
}; | ||
}, [isActive, counter, onFinish]); | ||
}, [isActive, counter.count, onFinish]); | ||
@@ -178,0 +178,0 @@ function pause() { |
@@ -144,3 +144,3 @@ 'use strict'; | ||
intervalId = setInterval(function () { | ||
if (counter >= 1) { | ||
if (counter.count >= 1) { | ||
setCounter(function (counter) { | ||
@@ -159,6 +159,6 @@ return _objectSpread2(_objectSpread2({}, counter), {}, { | ||
var secondCounter = counter % 60; | ||
var minuteCounter = Math.floor(counter % 3600 / 60); | ||
var hourCounter = Math.floor(counter % (3600 * 24) / 3600); | ||
var daysCounter = Math.floor(counter / (3600 * 24)); | ||
var secondCounter = counter.count % 60; | ||
var minuteCounter = Math.floor(counter.count % 3600 / 60); | ||
var hourCounter = Math.floor(counter.count % (3600 * 24) / 3600); | ||
var daysCounter = Math.floor(counter.count / (3600 * 24)); | ||
var computedSecond = String(secondCounter).length === 1 ? "0".concat(secondCounter) : secondCounter; | ||
@@ -182,3 +182,3 @@ var computedMinute = String(minuteCounter).length === 1 ? "0".concat(minuteCounter) : minuteCounter; | ||
}; | ||
}, [isActive, counter, onFinish]); | ||
}, [isActive, counter.count, onFinish]); | ||
@@ -185,0 +185,0 @@ function pause() { |
@@ -11,4 +11,3 @@ { | ||
"react-dom": "^16.9.0", | ||
"react-scripts": "^3.0.1", | ||
"reactjs-countdown-hook": "^1.0.3" | ||
"react-scripts": "^3.0.1" | ||
}, | ||
@@ -15,0 +14,0 @@ "scripts": { |
{ | ||
"name": "reactjs-countdown-hook", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "a simple count down timer hook for react with formatting", | ||
@@ -5,0 +5,0 @@ "author": "hoseinhamzei", |
@@ -18,3 +18,3 @@ import React, { useState, useEffect } from "react"; | ||
intervalId = setInterval(() => { | ||
if (counter >= 1) { | ||
if (counter.count >= 1) { | ||
setCounter((counter) => ({ ...counter, count: counter.count - 1 })); | ||
@@ -28,6 +28,6 @@ } else { | ||
const secondCounter = counter % 60; | ||
const minuteCounter = Math.floor((counter % 3600) / 60); | ||
const hourCounter = Math.floor((counter % (3600 * 24)) / 3600); | ||
const daysCounter = Math.floor(counter / (3600 * 24)); | ||
const secondCounter = counter.count % 60; | ||
const minuteCounter = Math.floor((counter.count % 3600) / 60); | ||
const hourCounter = Math.floor((counter.count % (3600 * 24)) / 3600); | ||
const daysCounter = Math.floor(counter.count / (3600 * 24)); | ||
@@ -58,3 +58,3 @@ const computedSecond = | ||
return () => clearInterval(intervalId); | ||
}, [isActive, counter, onFinish]); | ||
}, [isActive, counter.count, onFinish]); | ||
@@ -61,0 +61,0 @@ function pause() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
691417
13800