react-day-picker v2.0.0 Release Notes
Release Date: 2016-05-15 // almost 8 years ago-
π This release mainly improves the componentβs API (thus some breaking changes) and add some new props.
β Code has been split in multiple components and tests have been rewritten with β enzyme. It should be easier to add and test the upcoming new features!
π Thanks everyone for the support and for the help on making this component better π€ If you have issues or suggestions, don't forget the Spectrum Chat!
π₯ Breaking changes
- The
onDay*
event handlers receive as third argument an object of modifiers instead of an array.
This mean that if you where writing:
onDayClick(e, day, modifiers) { if (modifiers.indexOf('selected') > -1) { console.log('This day is selected') } }
you must now write:
onDayClick(e, day, modifiers) { if (modifiers.selected === true) { console.log('This day is selected') } }
π or better:
onDayClick(e, day, { selected }) { if (selected) { console.log('This day is selected') } }
β Removed
onDayTouchTap
. UseonDayClick
instead. If you need more granularity over touch events, you can use the newonDayTouchStart
andonDayTouchEnd
props. See #153 for more details.π Fixed import with CommonJS modules (#136).
0οΈβ£ This affects code using
require('react-day-picker').default
or similar syntax, which was required for v1.3.0. Now you canrequire('react-day-picker')
as 0οΈβ£ usual, i.e. without specifyingdefault
. If you are using ES2015 modulesimport DayPicker from 'react-day-picker'
, this change shouldn't affect you.- π New
formatDay
function in LocaleUtils.
If you are using your π custom LocaleUtils to localize the calendar, you need to implement this function as well, which is required to format the newly added π aria-label attribute (see the π documentation for an example). If you are localizing π using moment, this change shouldn't affect you.
π New props
- π New
disabledDays
andselectedDays
props. They receive a function(day) => Bool
as value to easily define which day should have theselected
ordisabled
modifiers. See #34 for more details.
So if you were writing something like:
<DayPicker modifiers={ ({ selected: day => isDaySelected(day) }, { disabled: day => isDayDisabled(day) }) } />
now you can write:
<DayPicker selectedDays={day => isDaySelected(day)} disabledDays={day => isDayDisabled(day)} />
- β Added
reverseMonths
prop to render the most recent month first. (#147 by [sonrtomas](sonrtomas)) - β Added
onDayKeyDown
,onDayTouchStart
,onDayTouchEnd
props.
π Improvements
- Navigate between weeks or years using left/right or up/down arrow keys (#132 by limscoder)
- β Added various
aria-*
attributes (#132 by limscoder)
π Bug fixes
- Navigation with keyboard when using
fromMonth
orendMonth
- The