# setMessageCollectionHandler bug

**URL:** <https://community.sendbird.com/t/setmessagecollectionhandler-bug/5702>\
**Category:** JavaScript\
**Tags:** chatsdk, react-native\
**Created:** [September 30, 2022, 3:38am UTC](https://community.sendbird.com/t/setmessagecollectionhandler-bug/5702 "2022-09-30T03:38:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GabrielLim\_ML](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/gabriellim_ml/32/2761_2.png) [@GabrielLim\_ML](https://community.sendbird.com/u/GabrielLim_ML)\
**Post date:** [September 30, 2022, 3:38am UTC](https://community.sendbird.com/t/setmessagecollectionhandler-bug/5702/1 "2022-09-30T03:38:31Z")

</div>

I am utilising `onMessagesAdded` event from `setMessageCollectionHandler` to handle showing new messages in message list view.

However, I realise if user navigate in & out of chatrooms too fast (where setMessageCollectionHandler is called for each chatroom on each enter), when (s)he tries to send a message in the chatroom, (s)he could receive two or more times `onMessageAdded` event trigger.

I suspect there’s some kind of race condition inside your setMessageCollectionHandler and ultimately didn’t manage to dispose the old handler before setting a new one on the same chatroom - ending up with two or more handlers listening to the same event and dispatching the same actions multiple times.

Sendbird Version - v3.1.17
