# Uncaught TypeError: Cannot read properties of undefined (reading 'forEach')

**URL:** <https://devforum.zoom.us/t/uncaught-typeerror-cannot-read-properties-of-undefined-reading-foreach/70107>\
**Category:** Web\
**Created:** [June 7, 2022, 7:33pm UTC](https://devforum.zoom.us/t/uncaught-typeerror-cannot-read-properties-of-undefined-reading-foreach/70107 "2022-06-07T19:33:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shoaib](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/shoaib/32/28580_2.png) [@shoaib](https://devforum.zoom.us/u/shoaib)\
**Post date:** [June 7, 2022, 7:33pm UTC](https://devforum.zoom.us/t/uncaught-typeerror-cannot-read-properties-of-undefined-reading-foreach/70107/1 "2022-06-07T19:33:33Z")

</div>

Hey @tommy and @vic.yang ,  
When screen share is already going on and I start video call as well then I’m getting below mentioned error, and after this error users video doesn’t render.

**Browser Console Error**

> f7be4d41-54d4-4be0-8b9f-9c8a36354d96:1 Uncaught TypeError: Cannot read properties of undefined (reading ‘forEach’)  
> at f.Clear\_OffScreenCavas (f7be4d41-54d4-4be0-8b9f-9c8a36354d96:1:190959)  
> at f7be4d41-54d4-4be0-8b9f-9c8a36354d96:1:163236

**Which Web Video SDK version?**  
1.3.0

Any idea on what could be the reason of this issue? and how can I avoid such issues?

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [June 8, 2022, 6:09am UTC](https://devforum.zoom.us/t/uncaught-typeerror-cannot-read-properties-of-undefined-reading-foreach/70107/2 "2022-06-08T06:09:29Z")

</div>

Hey @shoaib

Thanks for your feedback.

Did you have the same issue with our sample app? Could you share the code snippet for us to troubleshoot?

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![shoaib](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/shoaib/32/28580_2.png) [@shoaib](https://devforum.zoom.us/u/shoaib)\
**Post date:** [June 9, 2022, 7:27pm UTC](https://devforum.zoom.us/t/uncaught-typeerror-cannot-read-properties-of-undefined-reading-foreach/70107/3 "2022-06-09T19:27:36Z")

</div>

hey @vic.yang , I was able to resolve this.

So, when there is only screenshare on then I was not rendering video canvas, and only If user start video call then video canvas was getting rendered (or constructed). This destruction and reconstruction of video canvas was I think causing OffScreenCavas issue.

Now, I just hide video canvas when there only screenshare on.

Maybe you can also explicitly mention this somewhere in the Video SDK guide that we need to have both video canvas and screen share canvas rendered every time in the application to avoid destruction and reconstruction of canvases.

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [June 10, 2022, 8:51pm UTC](https://devforum.zoom.us/t/uncaught-typeerror-cannot-read-properties-of-undefined-reading-foreach/70107/4 "2022-06-10T20:51:20Z")

</div>

Hey @shoaib ,

Thanks for the feedback. I agree this would be valuable for the docs.

When you say destruction and reconstruction of the Video / Canvas do you mean you were removing it from the DOM?

We can update our docs to guide on using CSS hide/display properties and not DOM tree removal if that is what you are proposing. 🙂

-Tommy

---

<div class="post-metadata">

**Author:** ![shoaib](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/shoaib/32/28580_2.png) [@shoaib](https://devforum.zoom.us/u/shoaib)\
**Post date:** [June 11, 2022, 11:23am UTC](https://devforum.zoom.us/t/uncaught-typeerror-cannot-read-properties-of-undefined-reading-foreach/70107/5 "2022-06-11T11:23:23Z")

</div>

> [@tommy](#):
>
> When you say destruction and reconstruction of the Video / Canvas do you mean you were removing it from the DOM?

Yes.

> [@tommy](#):
>
> We can update our docs to guide on using CSS hide/display properties and not DOM tree removal if that is what you are proposing.

Yeah, clearly its causing the issue, So why not mention it somewhere as well, but its just a suggestion 🙂

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [June 14, 2022, 10:36pm UTC](https://devforum.zoom.us/t/uncaught-typeerror-cannot-read-properties-of-undefined-reading-foreach/70107/6 "2022-06-14T22:36:47Z")

</div>

Hey @shoaib ,

The docs will be updated to reflect this here: [Video](https://marketplace.zoom.us/docs/sdk/video/web/essential/video#render-participant-videos)

It will be published later this week. 🙂

Thanks again for the suggestion!

-Tommy

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [July 15, 2022, 8:36am UTC](https://devforum.zoom.us/t/uncaught-typeerror-cannot-read-properties-of-undefined-reading-foreach/70107/7 "2022-07-15T08:36:56Z")

</div>

Closed on July 15, 2022, 8:36am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
