Skip to content
Advertisement

Fixing Uncaught TypeError: Cannot read properties of undefined (reading ‘style’)

I’m trying to make a slideshow in my react app. I’m using the below function for the slideshow.

JavaScript
JavaScript

When I run the code the slideshow works. But as soon as I refresh the page all the contents in the page disappears and I get the following error in my console.Screenshot of the Error

I’m not quite sure why it stops working once the page is refreshed. It would be great if someone could guide me on how to fix this.

Advertisement

Answer

it seems that you are working with reactjs, it’s better to change your code with this :

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement