Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
use-stay-awake-lp
Advanced tools
React hook that will help the device stay awake while actively using your website or app.
React hook that make device stay awake while actively using your website.
Using Yarn
yarn add --dev use-stay-awake
Using NPM
npm install --save use-stay-awake
import React from "react";
import useStayAwake from "use-stay-awake";
function App() {
const device = useStayAwake();
return (
<div>
<p>
Status:
<span>
{device.canSleep
? "Device is allowed to sleep"
: "Device is not allowed to sleep"}
</span>
</p>
<button
onClick={() => {
device.preventSleeping();
}}
>
Prevent Sleeping
</button>
<button
onClick={() => {
device.allowSleeping();
}}
>
Allow Sleeping
</button>
</div>
);
}
export default App;
Prop Name | Type | Description |
---|---|---|
canSleep | boolean default: true | Indicator if the device allowed to sleep. |
preventSleeping | function | Function that prevent the device from sleeping. |
allowSleeping | function | Function that allow the device from sleeping. |
v9-11
v12-84
v22-81
v4-87
v4-14-TP
v16-69
v3.2-14.0
v4.4-81
v12-46
v84
v68
v12.12
v4-12.0
v10.4
v7.12
v2.5
Thank you so much for contributing! :blue_heart:
Clone the repository
git clone https://github.com/roldanjr/use-stay-awake
Locate library folder
cd use-stay-awake
Install library dependencies
yarn install or npm install
Locate demo folder and install dependencies
cd demo
yarn install or npm install
Start development server under root folder
yarn develop or npm run develop
MIT © Roldan Montilla Jr
FAQs
React hook that will help the device stay awake while actively using your website or app.
The npm package use-stay-awake-lp receives a total of 10 weekly downloads. As such, use-stay-awake-lp popularity was classified as not popular.
We found that use-stay-awake-lp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.