react keep screen on
// Download the nosleep.js bundle
// npm install nosleep.js
// Import and declare NoSleep
// REACT CODE STARTS HERE
import React from 'react';
import NoSleep from 'nosleep.js';
var noSleep = new NoSleep();
const WakeButton = () => {
return(
<div>
{/* Enable noSleep by wrapping this code in a user input event handler (such as a button) */}
<button onClick={() => {
document.addEventListener('click', function enableNoSleep() {
document.removeEventListener('click', enableNoSleep, false);
noSleep.enable();
}, false);
}}>Enable noSleep</ button>
{/* Disable noSleep */}
<button onClick={() => {
noSleep.disable();
}}>Disable noSleep</ button>
</div>
)
}
export default WakeButton;
Also in JavaScript:
- angular input press enter
- push item to array js
- angularjs find and update object in array
- how to add onclick event in javascript
- javascript switch statement multiple cases
- set css variable from javascript
- momentjs docs
- javascript style inline react
- parsley validation checkbox alignment
- how to use the replace method in javascript
- month name array javascript
- shorthand if in javascript with return
- capitalize
- sqrt javascript
- cordova load javascript without cache
- angular stable version
- js index of
- javascript method to see if item exists in array
- javascript .tolowercase
- angular transition animation
- javascript array remove element
- javascript check if key exists in object
- reactjs start project
- javascript have special characters