requestAnimationFrame not a function error


#1

I get following error when trying to use requestAnimationFrame function. Is there a solution to this or should I just use while() loop?


#2

If I’m understanding correctly, you’re trying to call this function. Given that it is on the window object, I would assume that this object does not exist outside of the renderer process. Since the error specifically mentions the main process … I assume you’re calling it on an instance or subclass of BrowserWindow, which is not the same thing as the Window class.

Check the Quick Start tutorial in the documentation for more information on the difference between the main process and renderer process.


#3

Is there a way I can access window class? Sorry for noob questions.


#4

You can, from inside a renderer process. Look at it this way:

The Electron framework launches as a normal desktop app, like Chrome before the window is actually opened. This is called the main process.

Then you start a BrowserWindow and load a page into it, like after the Chrome window opens and you connect to a website which loads a page inside the Chrome window. This is called the renderer process. The window object you’re trying to access only exists inside that page you loaded.

Also see this topic that talks a lot about the two processes and how they are commonly used:


#5

Thanks, that helped a lot. Have a great day :smiley: