Skip to content

Instantly share code, notes, and snippets.

@MkLHX
Created February 4, 2019 16:59
Show Gist options
  • Save MkLHX/27be71a30588c820dead8d25b980cccb to your computer and use it in GitHub Desktop.
Save MkLHX/27be71a30588c820dead8d25b980cccb to your computer and use it in GitHub Desktop.
wcs_quest_cycle_de_vie
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;
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