Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-wakelock

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-wakelock

a React component that keeps the browser/smartphone awake (aka. "no sleep")

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React wake-lock component

NPM

Introduction

This is an invisible React component that tries to keep the browser/client awake - especially for mobile devices.

Installation

npm i --save react-wakelock

How to use (READ THIS! IMPORTANT!)

import WakeLock from 'react-wakelock';


render() {
  
  return (
    <div>
      ...
      <WakeLock />
      ...
    </div>
  );

}

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.

How this works

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.

Props

  • preventSleep - (true by default). You can use this property to control the component behavior. Sleep is prevented only in preventSleep===true state.

Credits

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.

License

This project is licensed under the terms of the MIT license

Keywords

FAQs

Package last updated on 29 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc