react keep screen on code example
Example: react keep screen on
import React from 'react';
import NoSleep from 'nosleep.js';
var noSleep = new NoSleep();
const WakeButton = () => {
return(
<div>
{}
<button onClick={() => {
document.addEventListener('click', function enableNoSleep() {
document.removeEventListener('click', enableNoSleep, false);
noSleep.enable();
}, false);
}}>Enable noSleep</ button>
{}
<button onClick={() => {
noSleep.disable();
}}>Disable noSleep</ button>
</div>
)
}
export default WakeButton;