src/components/Clock.tsx   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 20
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 15
mnd 0
bc 0
fnc 1
dl 0
loc 20
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A Clock.tsx ➔ Clock 0 15 1
1
import React, {useState, useEffect} from "react";
2
3
function Clock(): JSX.Element {
4
  const [date, setDate] = useState<Date>(new Date());
5
6
  useEffect(() => {
7
    const interval = setInterval(() => {
8
      setDate(new Date());
9
    }, 1000);
10
11
    return () => {
12
      clearInterval(interval);
13
    };
14
  });
15
16
  return <span>{date.toLocaleTimeString()}</span>;
17
}
18
19
export default Clock;
20