-
-
Save Daltonic/bf6c176e52493ca256faa241ebe2e810 to your computer and use it in GitHub Desktop.
Dapp Votes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { initCometChat, checkAuthState } from '@/services/chat' | |
import { useEffect } from 'react' | |
import { globalActions } from '@/store/globalSlices' | |
import { useDispatch } from 'react-redux' | |
const CometChatNoSSR = () => { | |
const { setCurrentUser } = globalActions | |
const dispatch = useDispatch() | |
useEffect(() => { | |
setTimeout(async () => { | |
if (typeof window !== 'undefined') { | |
await initCometChat() | |
checkAuthState().then((user) => { | |
dispatch(setCurrentUser(JSON.parse(JSON.stringify(user)))) | |
}) | |
} | |
}, 500) | |
}, [dispatch, setCurrentUser]) | |
return null | |
} | |
export default CometChatNoSSR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment