Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import React from "react";
  2. import "./Bomb.css";
  3.  
  4. class Bomb extends React.Component {
  5. state = {
  6. count: 0
  7. };
  8. componentDidMount() {
  9. let counter = this.state.count;
  10. console.log("counter value", counter);
  11. this.interval = setInterval(() => {
  12. counter++;
  13. this.setState({
  14. count: counter
  15. });
  16. }, 1000);
  17. }
  18.  
  19. componentWillUnmount() {
  20. clearInterval();
  21. }
  22.  
  23. render() {
  24. if (this.state.count >= 8) {
  25. return (
  26. <div className="bomb-container">
  27. <h1>BOOOOOOOMMMMM</h1>
  28. </div>
  29. );
  30. } else if (!(this.state.count % 2)) {
  31. console.log("SHOULDbe EVEN", this.state.count);
  32. return (
  33. <div className="bomb-container">
  34. <h1>TICK</h1>
  35. </div>
  36. );
  37. } else {
  38. console.log("is Odd?", this.state.count);
  39. return (
  40. <div className="bomb-container">
  41. <h1>TOCK</h1>
  42. </div>
  43. );
  44. }
  45. }
  46. }
  47.  
  48. export default Bomb;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement