1
- import React , { useState , useEffect , useCallback } from 'react' ;
1
+ import React , { useState , useEffect , useCallback , useContext } from 'react' ;
2
2
import toast , { Toaster } from 'react-hot-toast' ;
3
3
import { onMessageListener } from '../../firebase' ;
4
4
import { AiOutlineClose } from 'react-icons/ai' ;
5
5
import logo from '../../assets/images/logo.png' ;
6
+ import CredentialsContext from '../../context/CredentialsContext' ;
6
7
7
8
const ToastDisplay = ( { id, notification } ) => {
8
9
return (
@@ -31,6 +32,7 @@ const ToastDisplay = ({ id, notification }) => {
31
32
32
33
const HandlerNotification = ( ) => {
33
34
const [ notification , setNotification ] = useState ( { title : '' , body : '' } ) ;
35
+ const { getData } = useContext ( CredentialsContext ) ;
34
36
35
37
const showToast = useCallback (
36
38
( ) => toast ( ( t ) => < ToastDisplay id = { t . id } notification = { notification } /> ) ,
@@ -50,6 +52,7 @@ const HandlerNotification = () => {
50
52
title : payload ?. notification ?. title ,
51
53
body : payload ?. notification ?. body ,
52
54
} ) ;
55
+ getData ( ) ;
53
56
} )
54
57
. catch ( ( err ) => {
55
58
console . log ( 'Failed to receive message:' , err ) ;
@@ -60,10 +63,10 @@ const HandlerNotification = () => {
60
63
messageListener ( ) ;
61
64
}
62
65
} ;
63
- } , [ ] ) ;
66
+ } , [ getData ] ) ;
64
67
65
68
return (
66
- < Toaster />
69
+ < Toaster />
67
70
) ;
68
71
} ;
69
72
0 commit comments