Created
February 4, 2019 16:59
-
-
Save MkLHX/27be71a30588c820dead8d25b980cccb to your computer and use it in GitHub Desktop.
wcs_quest_cycle_de_vie
This file contains hidden or 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 React, { Component } from "react"; | |
import "./App.css"; | |
import MyTimer from "./MyTimer"; | |
class App extends Component { | |
render() { | |
return ( | |
<div className="App"> | |
<header className=""> | |
<h1 className="App-title">Travels</h1> | |
</header> | |
<MyTimer /> | |
</div> | |
); | |
} | |
} | |
export default App; |
This file contains hidden or 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 React, { Component } from "react"; | |
class MyTimer extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { timer: 0 }; | |
} | |
componentDidMount() { | |
setInterval(() => { | |
this.setState({ timer: this.state.timer + 1 }); | |
}, 1000); | |
} | |
componentDidUpdate() { | |
console.log("un update a eu lieu"); | |
} | |
render() { | |
return ( | |
<div> | |
<p>MyTimer</p> | |
<span>{this.state.timer}</span> | |
</div> | |
); | |
} | |
} | |
export default MyTimer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment