src/hooks/toastFunction.js   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 14
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
A toastFunction.js ➔ useToastFunction 0 10 2
1
import { useState, useEffect } from "react";
2
3
function useToastFunction(toastRef) {
4
    const [toast, setToast] = useState(null);
5
    useEffect(() => {
6
        if (toastRef.current && toastRef.current.toast) {
7
            setToast(() => toastRef.current.toast);
8
        }
9
        // eslint-disable-next-line react-hooks/exhaustive-deps
10
    }, [toastRef, toastRef.current]);
11
    return toast;
12
}
13
14
export default useToastFunction;