Live Site weird behavior - refreshing non-stop

My site seems to go on a tailspin- reloading infinitely with the following flood of message if I look in the console.
“Error: WixCode Static Events Error: could not find component in the given static event behavior data”
When I move all my event handler code into the $w.onReady() function, this behavior stops.

But Wix recommendation is not to place static event handlers inside onReady().
The following code should not be placed inside the onReady() event handler:

  • Static event handlers that are wired using the Properties panel in the Editor are not placed inside the onReady() event handler.

  • return statements containing synchronous functions, especially if there is no impact on rendering (such as a query) and no need for SEO. Avoiding these return statements can improve performance.
    Wix Support is not being particularly helpful in troubleshooting this :frowning:

Hey, can you please post your site’s url so we can have a better look.
Thanks.

Hello, the url is → www.wring.online Thanks

I don’t see any issues with event handlers - static or otherwise.

You will need to determine what the cause of the refresh is. I suspect that the following code is the cause:

 if (session.getItem("active") !== "true") {
        wixUsers.logout();
 }

Try commenting out different sections of your onReady() code to see what is the causing the issue.

Thanks Yisrael, commenting out that code seems to have fixed the issue.
But I do need that bit of logic working, I have had this code in this manner for a while now, wix used to throw an error and progress normally in case the logout() call is made if no users are logged in.
Didn’t realize this could cause the whole site to go on a refresh frenzy.
Thanks again, I will re-implement that logic.

This is just conjecture…

I suspect that getItem(“active”) returns undefined or null. Since no value for active as saved to storage, wixUsers.logout() keeps being called.

What does active mean? And why do you want to logout if active is true.

Yes, return of undefinded/null makes sense.
I want to logout if active is not true. I have a custom login mechanism which sets active to true on successful login.

You’ll need to find another condition for doing the logout based on your requirements. At least you know what the problem is now.

Yes, I will :slight_smile: Thanks heaps for helping out. Cheers!