tawk / tawk-messenger-react

Official React plugin for Tawk messenger
https://www.tawk.to
Other
23 stars 15 forks source link

Cannot read properties of undefined (reading '$socket') #36

Open yongjiabidot opened 4 months ago

yongjiabidot commented 4 months ago

I tried 2 approaches below but still encountered the same issue. May I know how to resolve this issue?

1) use @tawk.to/tawk-messenger-react, const onLoad = () => { console.log('Here', tawkMessengerRef); tawkMessengerRef.current.setAttributes({ name: 'test', email: 'test@gmail.com', }); };

image

2) useeffect to check if authenticated useEffect(() => { if (isLoggedIn && store.user) { // const hash = hashInBase64(store.user.email, window.TAWK_APIKEY); if (window.Tawk_API) { window.Tawk_API.setAttributes( { name: store.user.loginName ?? '', email: store.user.email ?? '', // hash: hash, }, function (error) { if (error) { console.error('Tawk update user information error:', error); } }, ); } } }, [store.user]);

jaoaustero commented 1 week ago

Hi @yongjiabidot does the error still occurs? since we release a lot of updates before we check this issue

Pushkar952 commented 1 week ago

still getting this issue

jaoaustero commented 1 week ago

Hi @Pushkar952 I run a test now but I can't replicate what you encounter about the $socket connection. In my test I use next js + react js 18 version.

image image