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

screen-wake-lock

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

screen-wake-lock

React library to prevent computer from entering sleep mode

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
decreased by-23.53%
Maintainers
1
Weekly downloads
 
Created
Source

screen-wake-lock.js

React library to prevent device from entering sleep mode when app is in active tab.

Installation

# Install using npm
npm install screen-wake-lock
# Install using yarn
yarn add screen-wake-lock

Usage

Prevent device from entering sleep app-wide using ScreenWakeLock component

import React from 'react';
import ReactDOM from 'react-dom';
import ScreenWakeLock from 'screen-wake-lock';
import App from './App';

ReactDOM.render(
  <React.StrictMode>
    <ScreenWakeLock />
    <App />
  </React.StrictMode>,
  document.getElementById('root'),
);

Prevent device from entering sleep mode when a specific component is rendered using ScreenWakeLock component

import React from 'react';
import ScreenWakeLock from 'screen-wake-lock';

const SpecificComponent = () => {
  return (
    <>
      <ScreenWakeLock />
      <div>Sleepless in Seattle</div>
    </>
  );
};

export default SpecificComponent;

Prevent device from entering sleep mode when a specific component is rendered using useScreenWakeLock hook

import React from 'react';
import { useScreenWakeLock } from 'screen-wake-lock';

const SpecificComponent = () => {
  useScreenWakeLock();
  return <div>Sleepless in Seattle</div>;
};

export default SpecificComponent;

Use useScreenWakeLock in debug mode

useScreenWakeLock takes an optional parameter debug. When passed true it will print the status of the wake lock to the console whenever it gets locked or released. for instance when navigating away from the browser tab where the app is running and back. This can be a convenient way to test that the hook is working.

import React from 'react';
import { useScreenWakeLock } from 'screen-wake-lock';

const SpecificComponent = () => {
  useScreenWakeLock(true);
  return <div>Sleepless in Seattle</div>;
};

export default SpecificComponent;

// Screen Wake Lock released: true
// Screen Wake Lock released: false

For contributors

Publishing a new version

Check that linting, formatting, build and tests pass

npm run lint
npm run format
npm run build
npm test

Bump version

npm version [major | minor | patch]

Publish to NPM

npm publish

Keywords

FAQs

Package last updated on 16 Aug 2021

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