Total Complexity | 2 |
Complexity/F | 2 |
Lines of Code | 14 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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; |