const outNum = (num) => {
let t = Math.random(time/(num/step))
let n = 0;
let interval = setInterval(() => {
n = n + step;
if(n == num){
clearInterval(interval)
}
}, t);
return n;
}
function Counter({ val, time }) {
const [ currVal, setCurrVal ] = useState(0);
useEffect(() => {
currVal !== val && setTimeout(setCurrVal, time, currVal + 1);
}, [ currVal ]);
return <div>{currVal}</div>;
}