react keep screen on

JavaScript
// 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;
Source

Also in JavaScript: