# React component page executing too many times

**URL:** <https://forum.social.plus/t/react-component-page-executing-too-many-times/912>\
**Category:** JS SDK\
**Created:** [September 7, 2023, 9:27pm UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912 "2023-09-07T21:27:07Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhishek](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@abhishek](https://forum.social.plus/u/abhishek)\
**Post date:** [September 7, 2023, 9:27pm UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912/1 "2023-09-07T21:27:07Z")

</div>

Hello, I am working with the Amity UIKit for Web (react), and also adding a bit of code for my app’s purpose.

On the `src/chat/components/Chat/index.js`, I have added some code that gets the user’s meta data, accesses a certain property (`teamId`), and automatically creates a new chat channel by that id, and if it already exists, joins that channel.

My issue is that when I am running the app, this page get its code run too many times repetitively, and the console logs get spammed.  
For example, there’s a console log at line 28 (“Hit the application page […]”) that keeps getting printed, and therefore makes the page lag.

Could you have a look at this class, and give me a pointer as to what could be causing this page to re-run this code so many times?

> **[import React, { useState, useEffect } from 'react';import PropTypes from 'prop...](https://pastebin.com/SauLXvmz)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

(Let me know if I should take it off pastebin and share another way)

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 8, 2023, 5:31am UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912/2 "2023-09-08T05:31:42Z")

</div>

hi @abhishek ,

Which JS SDK vers. are you using?

Thank you,  
Amity Support

---

<div class="post-metadata">

**Author:** ![abhishek](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@abhishek](https://forum.social.plus/u/abhishek)\
**Post date:** [September 8, 2023, 6:01am UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912/3 "2023-09-08T06:01:12Z")

</div>

Hi team,

I believe our forked version of the Amity web UI Kit repo has **2.15.6 (2023-04-10)** latest in the change logs.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 8, 2023, 12:02pm UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912/4 "2023-09-08T12:02:16Z")

</div>

Thank you, we’re passing to the team to help check :))

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 11, 2023, 11:16am UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912/5 "2023-09-11T11:16:48Z")

</div>

Hello, could we please gather more information regarding the log entry at line 28? What is the purpose of adding this log entry?

---

<div class="post-metadata">

**Author:** ![abhishek](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@abhishek](https://forum.social.plus/u/abhishek)\
**Post date:** [September 11, 2023, 12:56pm UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912/6 "2023-09-11T12:56:23Z")

</div>

Hello, the console log at line 28 was just added initially to see how/when this page loads, and to debug the `defaultChannelId`.  
I can remove the log as it serves no purpose, but it let me know that this react component was executing its code too many times.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 12, 2023, 1:27pm UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912/7 "2023-09-12T13:27:12Z")

</div>

Hello, I’ve discussed this with the team, and we plan to log it as a performance improvement in our future plans. I just wanted to confirm that it isn’t causing any crashes or issues, is that correct?

---

<div class="post-metadata">

**Author:** ![abhishek](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@abhishek](https://forum.social.plus/u/abhishek)\
**Post date:** [September 12, 2023, 1:48pm UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912/8 "2023-09-12T13:48:10Z")

</div>

It (potentially) cause slowness/lag to the overall chat page and the input field typing, but not necessarily a crash.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 12, 2023, 3:07pm UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912/9 "2023-09-12T15:07:23Z")

</div>

Noted. Could you please elaborate on the severity of the slowness and lagging? This information will help us assess the issue’s priority. In the meantime, we will log it for future improvements.

---

<div class="post-metadata">

**Author:** ![abhishek](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@abhishek](https://forum.social.plus/u/abhishek)\
**Post date:** [September 13, 2023, 1:27pm UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912/10 "2023-09-13T13:27:48Z")

</div>

The severity seems critical based on the user experience.

After the chat is loaded, usernames/profile pictures take another second to load, and scrolling up and down shows delayed feedback.  
If you’ve had a chance to play with the code snippet I provided on the post, did you experience lag on your end?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 13, 2023, 2:18pm UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912/11 "2023-09-13T14:18:43Z")

</div>

Hello, we are aware of the lagging on the chat uikit performance - you may have noticed a slight delay of a few seconds when loading. Rest assured, we’ve taken note of this and have plans in place to make it more efficient.

---

<div class="post-metadata">

**Author:** ![abhishek](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@abhishek](https://forum.social.plus/u/abhishek)\
**Post date:** [September 19, 2023, 4:33pm UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912/12 "2023-09-19T16:33:58Z")

</div>

Hello team,

There’s also an issue with some leak on the chat of the UI Kit.  
When I open the team chat, and leave it on for 5~ minutes, it starts to lag, and eventually it crashes. Are you experiencing this as well?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 20, 2023, 11:42am UTC](https://forum.social.plus/t/react-component-page-executing-too-many-times/912/13 "2023-09-20T11:42:45Z")

</div>

It shouldn’t crash, we don’t experience this on our end. Could you please help share the error/log?
