BugiDev / react-native-calendar-strip

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

Setting the start day of the week #210

Closed tcavalin closed 4 years ago

tcavalin commented 4 years ago

Hey, guys. How can I set the week start day? I try the "startingDate" combinated with "useIsoWeekday", but it only works with the "scrollable" parameter as 'true'.

startingDate={new moment().startOf('week')} useIsoWeekday={false} // scrollable={true}

Thank's for the project! It's very helpful!

peacechen commented 4 years ago

This works in the example project in this repo:

  <CalendarStrip
    style={{height:200, paddingTop: 20, paddingBottom: 10}}
    useIsoWeekday={false}
    startingDate={"2020-07-13"}
  />

Change startingDate to any other date and it renders there. The prop accepts any Moment-parseable value.

new moment().startOf('week') may not be returning what you expect. Inspect that value by assigning a variable to it.

tcavalin commented 4 years ago

Thanks for the reply, @peacechen. I found the problem.

I was running an unnecessary call to the 'updateWeekView' method. This call was overriding the startingDate prop.

this.refs.myCalendarStrip.updateWeekView(this.state.selectedDate);