Skip to content

Commit

Permalink
refactor(components): remove deprecated lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
yassinedoghri committed May 12, 2018
1 parent e58058a commit 16f75d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions src/containers/Countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@ class Countdown extends Component {
};
}

constructor() {
super();
this.state = { time: {}, seconds: 0 };
constructor(props) {
super(props);

this.state = {
time: Countdown.secondsToTime(props.from),
seconds: props.from
};
this.timer = 0;
this.startTimer = this.startTimer.bind(this);
this.countDown = this.countDown.bind(this);
}

componentWillReceiveProps() {
const { from, result, isGamePaused } = this.props;
componentDidMount() {
const { result, isGamePaused } = this.props;
if (
(result.length === 0 && this.timer === 0) ||
(result.length === 0 && isGamePaused)
) {
this.setState({ seconds: from });
const timeLeftVar = Countdown.secondsToTime(this.state.seconds);
this.setState({ time: timeLeftVar });
this.startTimer();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/withTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ const withTracker = (WrappedComponent, options = {}) => {
trackPage(page);
}

componentWillReceiveProps(nextProps) {
componentDidUpdate(prevProps) {
const currentPage = this.props.location.pathname;
const nextPage = nextProps.location.pathname;
const nextPage = prevProps.location.pathname;

if (currentPage !== nextPage) {
trackPage(nextPage);
Expand Down

0 comments on commit 16f75d5

Please sign in to comment.