Passed
Push — master ( cbfbaf...1c4491 )
by Rohit
01:43 queued 12s
created

toastFunction.js ➔ useToastFunction   A

Complexity

Conditions 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 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;