BugiDev / react-native-calendar-strip

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

startingDate props on CalendarStrip is no longer accepting a Date object. #186

Closed rusticdeity closed 4 years ago

rusticdeity commented 4 years ago

When I was using version 1.4.1 I was able to pass in a startingDate prop as startingDate={moment(moment().startOf('week')).toDate()} which is breaking with an error _.clone is not a function. from version 2.0.0. If this is a change that was made consciously then please update the documentation. Snack is here.

peacechen commented 4 years ago

Thanks for reporting this bug. The change was made to differentiate between defined and undefined startingDate since moment(undefined) returns today's date. I have pushed a fix for this and will publish a new version.

BTW -- the way you created the date results in two Moment constructors plus a JS Date constructor: moment(moment().startOf('week')).toDate()

That could be simplified to moment().startOf('week').

The corner case you reported is still valid because startingDate should support non-Moment input including "YYYY-MM-DD" strings.