# sb.groupChannel?.addGroupChannelHandler was undefined

**URL:** <https://community.sendbird.com/t/sb-groupchannel-addgroupchannelhandler-was-undefined/7907>\
**Category:** JavaScript\
**Tags:** group-channel, react-js\
**Created:** [July 23, 2023, 5:34pm UTC](https://community.sendbird.com/t/sb-groupchannel-addgroupchannelhandler-was-undefined/7907 "2023-07-23T17:34:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Funny\_Cat](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/funny_cat/32/4329_2.png) [@Funny\_Cat](https://community.sendbird.com/u/Funny_Cat)\
**Post date:** [July 23, 2023, 5:34pm UTC](https://community.sendbird.com/t/sb-groupchannel-addgroupchannelhandler-was-undefined/7907/1 "2023-07-23T17:34:18Z")

</div>

## **[Problem/Question]** // Detailed description of issue. I have inited SendBird with my key and I add sb.groupChannel?.addGroupChannelHandler to listen and receive a new message in the group. (I put it in useEffect) but i got undefined

// If problem, please fill out the below. If question, please delete.  
**[SDK Version]**  
// What version of the SDK are you using?  
“@sendbird/chat”: “^4.3.0”,

---

<div class="post-metadata">

**Author:** ![Chinmaya\_Gupta](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/chinmaya_gupta/32/1021_2.png) [@Chinmaya\_Gupta](https://community.sendbird.com/u/Chinmaya_Gupta)\
**Post date:** [July 27, 2023, 11:01am UTC](https://community.sendbird.com/t/sb-groupchannel-addgroupchannelhandler-was-undefined/7907/3 "2023-07-27T11:01:36Z")

</div>

Hello @Funny_Cat

Welcome to the Sendbird community!

If you are getting `undefined` when adding the group channel event handler in your React JS app, there could be a few possible reasons for this issue. Here are some suggestions to troubleshoot the problem:

1. Make sure you have initialized the Sendbird Chat SDK properly before adding the event handler. Check if you have called the `SendbirdChat.init()` method with the correct `appId` and `modules` parameters. Also, ensure that you have imported the necessary modules correctly.
2. Verify that you have imported the `GroupChannelHandler` class from the `@sendbird/chat/groupchannel` module correctly. Double-check the import statement and ensure that the module is installed in your project.
3. Check if the `sb.groupChannel` object is defined before adding the event handler. It’s possible that the `sb.groupChannel` object is not initialized properly or is not available at the time of adding the event handler. You can add a null check before adding the event handler to avoid any errors.

If the issue persists, please provide more details about your code implementation, including the initialisation process and where you are adding the event handler.
