A React component that keeps the browser/smartphone awake (aka. "no sleep"). Updated to work with React16
npm install @bitfly/react-wakelock-react16
This is an invisible React component that tries to keep the browser/client
awake - especially for mobile devices.
```
npm i --save react-wakelock-react16
`javascript
import WakeLock from 'react-wakelock-react16';
render() {
return (
}
`
Just add the component to your application. By default it is immediately
"enabled".
WARNING: Due to browser limitations the wake-lock is not effective
until the user first clicks/touches somewhere in the document. So, after
adding/enabling the component, it will not prevent sleep until the user
interacts with the page in some way (scrolling not being an interaction).
This limitation does not apply to iOS devices.
The component uses two methods, depending on the operating system.
On Android, a invisible dummy-video is played in the background.
On iOS, an (hopefully unnoticeable) dummy navigation is performed every 15
seconds.
- preventSleep - (true by default). You can use this property to control the preventSleep===true` state.
component behavior. Sleep is prevented only in
The component is based on NoSleep.js
by Rich Tibbett. However, it is implemented differently and also uses
different dummy videos that do not unnecessarily use CPU power.