BugiDev / react-native-calendar-strip

Easy to use and visually stunning calendar component for React Native.
MIT License
939 stars 327 forks source link

having issues displaying data from onDateSelected #195

Closed Vasault closed 4 years ago

Vasault commented 4 years ago

i'm not entirely sure if this is a performance issue or a bug behaviour from the onDateSelected prop, likely to be the second one.

In my onDateSelected={(date) => this.displayDate(date)} i'm passing the date parameter (day selected), and the function here

  displayData = (date) => {
    var currentDay = moment(date).format('YYYY/MM/DD');
    this.setState({ selectedDate: currentDay });
    this.dataList = HoursReportHistoryBusiness.GetInstance().getInfoHoursReport(this.state.dataSource, this.state.selectedDate);
  }

all it does is, i format the date, and save it on a state, then i pass that variable to this business layer function that display an object based on the day selected, so data was saved on a particular day, on that day, that object will be displayed on a flatlist.

problem is, i need to click/press twice in order to show the date, i'm already in doubt if this is an issue related to performance or the prop

Grabación de pantalla 2020-06-04 a la(s) 13 05 57

peacechen commented 4 years ago

Is CalendarStrip calling your callback on the first press? I would be very surprised if it doesn't call on first press but calls on the second. It's more likely that your component is not receiving or processing prop changes optimally. Set a breakpoint in your business component's componentDidUpdate to check whether the prop change makes its way there.

Vasault commented 4 years ago

Is CalendarStrip calling your callback on the first press? what do you mean by this :/

Vasault commented 4 years ago

ok i set two console.log on the business, and the moment i clicked on the date from calendar strip, immediately showed me both parameters on the business, so is capturing both parameters right away

Vasault commented 4 years ago

ok ok, i discovered something, the date value is not changing on the first click, but on the second :( why is this?

Vasault commented 4 years ago

SOLVED, it was the handling of states