import React from "react";
export default class Timer extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            timerDuration: props.timerDuration,
        };
    }
    //Every second, subtract a second.
    componentDidMount() {
        this.interval = setInterval(() => {
            let newTime = this.state.timerDuration - 1000;
            if (newTime <= 0) {
                this.props.ontimerDurationExpiration();
                if (this.interval)
                    clearInterval(this.interval);
            }
            else {
                this.setState({
                    timerDuration: newTime,
                });
            }
        }, 1000);
    }
    //Countdown clock.
    render() {
        return React.createElement("div", null,
            "Time remaining: ",
            this.state.timerDuration / 1000,
            " seconds");
    }
}
//# sourceMappingURL=timer.js.map