i cant pass this test
-
User Story #8: I can see an element with corresponding
id="time-left"
. NOTE: Paused or running, the value in this field should always be displayed inmm:ss
format (i.e. 25:00)
.class LengthController extends React.Component{
render(){
return(
<div id={this.props.Id}>
{this.props.text}
<div id={this.props.IdInc}></div>
<div id={this.props.IdDec}></div>
<div id={this.props.IdLen}>{this.props.display}</div>
</div>
)
}
}
class App extends React.Component{
constructor(){
super();
this.state = {
break_length: 5,
session_length: 25,
}
this.handleTimer = this.handleTimer.bind(this)
}
handleTimer(){
var temp = this.state.session_length * 60;
var minutes = Math.floor(temp / 60 );
var secondes = temp - minutes * 60 ;
minutes = minutes < 10 ? '0'+minutes : minutes
secondes = secondes < 10 ? '0'+secondes : secondes
return minutes+":"+secondes
}
handleReset = () =>{
this.setState({
break_length: 5,
session_length: 25,
});
this.handleTimer()
console.log("reset")
}
render(){
return(
<div>
<LengthController
Id="break-label"
IdDec="break-decrement"
IdInc="break-increment"
text="Break Length"
IdLen="break-length"
display={this.state.break_length}
/>
<LengthController
Id="session-label"
IdDec="session-decrement"
IdInc="session-increment"
text="Session Length"
IdLen="session-length"
display={this.state.session_length}
/>
<div id="timer-label">
Session
<div id="time-left">{this.handleTimer()}</div>
</div>
<div id="controle">
<div id="start_stop">Stop</div>
<div id="reset" onClick={this.handleReset} >Reset</div>
</div>
</div>
)
}
}
ReactDOM.render(<App />,document.getElementById('main'));