src/shared/hooks/useCustomEventDetail.ts
last analyzed

Complexity

Total Complexity 0
Complexity/F 0

Size

Lines of Code 16
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 11
mnd 0
bc 0
fnc 0
dl 0
loc 16
bpm 0
cpm 0
noi 1
c 0
b 0
f 0
1
import { useEffect, useState } from 'react'
2
3
const useCustomEventDetail = (eventName: string) => {
4
  const [eventState, setEventState] = useState<any>(1)
0 ignored issues
show
introduced by
Unexpected any. Specify a different type.
Loading history...
5
6
  const handleDetail = ({ detail }: CustomEventInit) => setEventState(detail)
7
8
  useEffect(() => {
9
    window.addEventListener(eventName, handleDetail, false),
10
      () => window.removeEventListener(eventName, handleDetail, false)
11
  }, [eventName])
12
13
  return eventState
14
}
15
16
export { useCustomEventDetail }
17