Created
November 9, 2016 02:26
-
-
Save takaki/ca57f2b3a42bddaca508c931c26cc6ec to your computer and use it in GitHub Desktop.
スマートフォン用のWebページでスリープを防ぐ ref: http://qiita.com/takaki@github/items/f6b0c2cb4aeeaa6aa518
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ npm install --save nosleep.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import NoSleep from 'nosleep.js/NoSleep' | |
class App extends Component { | |
constructor() { | |
super(); | |
this.noSleep = new NoSleep(); | |
this.state = {sleep: "Sleep"} | |
} | |
render() { | |
return ( | |
<div> | |
<button onClick={() => { | |
this.setState({sleep: "No Sleep"}); | |
this.noSleep.enable(); | |
}}>No Sleep | |
</button> | |
<button onClick={() => { | |
this.setState({sleep: "Sleep"}); | |
return this.noSleep.disable(); | |
}}>Sleep | |
</button> | |
{this.state.sleep} | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment