Topic: getValue - infinite loop
Anna Morawska
staff answered 2 years ago
Hi there,
what exactly do you want to achieve? If you want to update the state please check out this solution:
import React, { Component } from "react";
import { MDBDatePicker, MDBBtn } from "mdbreact";
class DateTimePickerPage extends Component {
state = {
date: new Date("12.12.2012"),
}
setDate = date => this.setState({ date: new Date(date) })
render(){
return(
<>
<div className="col-sm-3">
<MDBDatePicker value={this.state.date} getValue={this.updateStateValue} />
<MDBBtn onClick={() => this.setDate("10.20.2020")} size="sm" className="ml-4">Set Date "10.20.2020"</MDBBtn>
</div>
</>
)
}
}
export default DateTimePickerPage;
Answered
- User: Pro
- Premium support: No
- Technology: React
- MDB Version: 4.7.0
- Device: Dell Laptop
- Browser: Chrome
- OS: Ubuntu
- Provided sample code: No
- Provided link: No
Anna Morawska staff commented 3 years ago
Hi there, thank you for reporting this bug, we will take a closer look at this, and let you know as soon as possible. Best, Aniamaster@mastersistemas.net pro commented 3 years ago
Good morning, I have the same problem.Anna Morawska staff commented 3 years ago
Hello, thank you, it's already on our TODO list. Best, Aniakenjo commented 2 years ago
Any update on this? It's unusable as is, cannot update the state, because it will re-render, and call again.