Guest User

Untitled

a guest
Jul 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. const truth = [
  2. {question: "Question 1", hasAppeard: false},
  3. {question: "Question 2", hasAppeard: false},
  4. {question: "Question 3", hasAppeard: false},
  5. {question: "Question 4", hasAppeard: false}
  6. ]
  7.  
  8. const dare = [
  9. {question: "Question 5", hasAppeard: false},
  10. {question: "Question 6", hasAppeard: false},
  11. {question: "Question 7", hasAppeard: false},
  12. {question: "Question 8", hasAppeard: false}
  13. ]
  14.  
  15. export {truth, dare};
  16.  
  17. class App extends Component {
  18. constructor() {
  19. super();
  20. this.state = {
  21. currQuest: null,
  22. }
  23. }
  24.  
  25. handleRandomTruth = () => {
  26. this.setState({
  27. currQuest: truth[Math.floor(Math.random() * truth.length)]
  28. })
  29. }
  30.  
  31. handleRandomDare = () => {
  32. this.setState({
  33. currQuest: dare[Math.floor(Math.random() * dare.length)]
  34. })
  35. }
  36.  
  37. render() {
  38. return (
  39. <div className="App">
  40. <div className="timer">
  41. <CountdownTimer />
  42. </div>
  43.  
  44. <div className="current-player">
  45. <h3>current player</h3>
  46. </div>
  47.  
  48. <div className="next-player">
  49. <h3>next player</h3>
  50. </div>
  51.  
  52. <div className="questions">
  53. {this.state.currQuest ? <div>{this.state.currQuest.question}
  54. </div> : ''}
  55. </div>
  56.  
  57. <button className="btn-truth" onClick=
  58. {this.handleRandomTruth}>Truth</button>
  59. <button className="btn-dare" onClick=
  60. {this.handleRandomDare}>Dare</button>
  61. <button className="btn-home" >Home</button>
  62. </div>
  63. );
  64. }
  65. }
  66.  
  67. export default App;
Add Comment
Please, Sign In to add comment