Open nikolara opened 4 years ago
hi! i set my data from api in componentDidUpdate. I compare the prevProps with props. If the data is changed i set resourses and events. the next code is my implementation
componentDidUpdate(prevProps) {
const { dataSchedule } = this.props;
if (prevProps.dataSchedule !== dataSchedule) {
this.setState({ viewModel: null });
const today = moment().format(DATE_FORMAT);
const schedulerData = new SchedulerData(today, ViewTypes.Week, false, false, configuracion);
schedulerData.localeMoment.locale();
schedulerData.setResources(dataSchedule.instructores);
schedulerData.setEvents(dataSchedule.actividades);
schedulerData.documentWidth = this.props.width;
this.setState({
viewModel: schedulerData,
});
}
}
I am unable to find a way to make this happen, tried to setState with componentDidMount, componentWillMount, event tried to re-render the component when the state is set, and nothing works. Does someone have a solution for this maybe?