mirror of
https://github.com/usebruno/bruno.git
synced 2025-08-19 17:35:36 +02:00
feat: migration to electron + next complete
This commit is contained in:
30
renderer/components/StopWatch/index.js
Normal file
30
renderer/components/StopWatch/index.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
|
||||
const StopWatch = () => {
|
||||
const [milliseconds, setMilliseconds] = useState(0);
|
||||
|
||||
const tickInterval = 200;
|
||||
const tick = () => {
|
||||
setMilliseconds(milliseconds + tickInterval);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
let timerID = setInterval(() => tick(), tickInterval);
|
||||
return () => {
|
||||
clearInterval(timerID);
|
||||
};
|
||||
});
|
||||
|
||||
if(milliseconds < 1000) {
|
||||
return 'Loading...';
|
||||
}
|
||||
|
||||
let seconds = milliseconds/1000;
|
||||
return (
|
||||
<span>
|
||||
{seconds.toFixed(1)}s
|
||||
</span>
|
||||
)
|
||||
};
|
||||
|
||||
export default StopWatch;
|
Reference in New Issue
Block a user