modules/core/utils/useWindowDimensions.js   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 25
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 20
mnd 0
bc 0
fnc 1
dl 0
loc 25
ccs 5
cts 5
cp 1
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
A useWindowDimensions.js ➔ handleResize 0 3 1
1
import { useState, useEffect } from 'react'
2
import { getWindowDimensions } from '~/modules/core/utils/helpers'
3
4
/* istanbul ignore next */
5 11
const useWindowDimensions = () => {
6 23
  const [windowDimensions, setWindowDimensions] = useState(
7
    getWindowDimensions()
8
  )
9
10 23
  useEffect(() => {
11
    /* istanbul ignore next */
12
    function handleResize() {
13
      setWindowDimensions(getWindowDimensions())
14
    }
15
16 22
    window.addEventListener('resize', handleResize)
17
    /* istanbul ignore next */
18
    return () => window.removeEventListener('resize', handleResize)
19
  }, [])
20
21 23
  return windowDimensions
22
}
23
24
export default useWindowDimensions
25