I implemented an onUserLeft function on the channel handler and immediately started getting the following error every time it is invoked.
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'onUserLeft')
I am registering the handler inside of a useEffect after the connection with sendbird has been established. The event handler is firing because the desired effect is being observed, but I should not be receiving the error message in the console.
SendBird.min.js:6 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'onUserLeft')
at Array.forEach (<anonymous>)
at new Promise (<anonymous>)
at le (SendBird.min.js:6:23158)
at Function.value (SendBird.min.js:6:412325)
at e.value (SendBird.min.js:6:276705)
at c.onMessage (SendBird.min.js:6:94301)
at ws.onmessage (SendBird.min.js:6:88577)
Thanks for investigating @Tyler. I attempted to refactor using a similar strategy as your code sandbox, but couldn’t get a connection set up properly which ended up introducing a whole host of other errors.
Here are my relevant files. Maybe you can spot something I’m doing incorrectly…
A quick glance over the code you provided show any inherent issues that I can see. I do see you’re utilizing Typescript so I’m going to give that a go and see if there is any issues on the conversion from TS to JS.
I tested this in Typescript as well and didn’t have any issues. Just for the sake of ruling anything funky out, could you get a new instance of SendBird rather than importing sb from your common/sendbird?
It would look like this:
import SendBird from 'sendbird'
// Inside of the initialize useEffect function
const sb = SendBird.getInstance()
I highly doubt that is causing an issue but it’s the only key difference I see between our implementations.
I decided to just spend my efforts upgrading to v4 instead of trying to get rid of this error. However, I’m noticing that there are quite a few types that are not properly exported in v4. For example, the MessageType, SendableMessage, FileMessage, and UserMessage types are all inside of a chat/lib/__definition file that the ts compiler is not able to resolve during compilation. But it seems like we need these types to be able to coerce a message to the correct type so that we can access certain properties…
Anyway, I know this is not a little off topic to the original purpose of this thread. Let me know if you think I should open a new thread with these concerns. Thanks.
edit: I was looking forward to chatting with you all in the office hours today, but no one showed up. i’m still sitting in the zoom meeting as I’m typing this
I’m running into the same issue when leaving a channel. I haven’t implemented a custom handler.
It looks like for some reason channel is not being destructured properly from action.payload in reducers.js:
Uncaught TypeError: Cannot read properties of undefined (reading 'url')
at reducer (reducers.js:114:1)
at updateReducer (react-dom.development.js:16664:1)
at Object.useReducer (react-dom.development.js:17898:1)
at useReducer (react.development.js:1626:1)
at ChannelList (index.jsx:71:1)
at renderWithHooks (react-dom.development.js:16305:1)
at updateFunctionComponent (react-dom.development.js:19588:1)
at beginWork (react-dom.development.js:21601:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1)
It looks like your use case differs from the the originally reported issue as you’re utilizing the UIKit while the OP was using the Core SDK. I’d kindly ask you create a new topic so we can separate the use cases and approach the investigations separately.
In regards to the office hours, someone should be reaching out to you directly soon.