I know that this is some silly question but trust me i the state is not updating and i am unable to know why, I’m trying from hours but still its always same, below is my simple useEffect :
const [notificationData, setNotificationData] = useState(null);
useEffect(() => {
messaging().getInitialNotification().then(remoteMessage => {
if(remoteMessage){
console.log("this is remove message", remoteMessage)
setNotificationData(remoteMessage?.notification.body)
}
})
}, [])
Here all i need is to setNotificationData and i need that notification.body text to be showing in my View that it, but its just don’t update.
Here are the things I have verified before you asked,
-
Is remoteMessage?.notification.body have value? Yes I am 100% it does
have, value, even if i try with static value instead of
remoteMessage?.notification.body, its still same, doesn’t get
updated. -
Did i tried outside the getInitialNotification promise? Yes it works perfectly fine if i setNotificationData outside the promise, when i directly set state in useEffect.
I wonder, like by any chance its due to any behaviour or firebbase’s notification promise that state changes doesn’t work.