react-screen-wake-lock icon indicating copy to clipboard operation
react-screen-wake-lock copied to clipboard

Reaquire wake lock is fired, even when it shouldn't

Open andolf opened this issue 8 months ago • 0 comments

My use case is this:

I want to request the wake lock when I open a modal, so request is made in conjunction with a button press. When visibility changes, the wake lock is correctly released and then requested again when returning to the tab.

However, even when the modal is not open, the wake lock request is made simply because visibility changes on the document and the hook is rendered because there is no conditional checking whether it should reacquire the wake lock or not, simply that it does because the visibility has changed.

A fix for this would be to supply an a conditional option for when to reacquire on visibility change.

As a working example, check out the official demo over at MDN.

andolf avatar May 07 '25 10:05 andolf