-
Notifications
You must be signed in to change notification settings - Fork 2.2k
react day picker 8 migration
@blueprintjs/datetime components in Blueprint v6.0 will use react-day-picker v8.x, which has numerous API breaks from v7.x. To help you prepare for these breaks, @blueprintjs/datetime2 provides next-generation variants of datetime components which use the updated version of react-day-picker. You can migrate your code to use these components alongside Blueprint v5.0 for forwards-compatibility with v6.0.
Many prop names have changed. If you are using dayPickerProps on any @blueprintjs/datetime component to customize react-day-picker behavior, you may have to rename certain properties. See rdp's upgrading from v7 guide.
// used to disable Fridays in date picker
const fridayMatcher = {
- daysOfWeek: [5],
+ dayOfWeek: [5],
};
- <DatePicker
+ <DatePicker3
dayPickerProps={{
- showWeekNumbers: true,
+ showWeekNumber: true,
- firstDayOfWeek: 0,
+ weekStartsOn: 0,
- disabledDays: fridayMatcher,
+ disabled: fridayMatcher,
}}
/>react-day-picker has changed how custom modifiers are applied; this now requires more than one prop. Usually you will need to set both modifiers and modifiersClassNames to style custom modifiers. See the Custom modifiers documentation for more info.
Due to this API change, we have removed modifiers as a top-level prop on datetime components since it is not useful on its own. Instead, you may specify the modifiers object as a property inside dayPickerProps, alongside other react-day-picker customizations. The type of the modifiers object is now stricter (but mostly backwards-compatible).
const isDayOdd = (d: Date) => d.getDate() % 2 === 1;
- <DatePicker modifiers={{ odd: isDayOdd }} />
+ <DatePicker3 dayPickerProps={{ modifiers: { odd: isDayOdd }, modifiersClassNames: { odd: "odd" } }} />The localeUtils prop is no longer required or supported. You can simply provide a locale code string to the locale prop and the components will automatically load the relevant date-fns Locale and re-render using the relevant i18n strings. Make sure your locale code is supported as one of date-fns' built-in locales.
- FAQ
- 6.x Changelog
- 5.x Changelog
- 5.0 pre-release changelog
- 4.x Changelog
- v4.0 & v5.0 major version semantic swap
- v6.0 changes
- Spacing System Migration: 10px to 4px
- react-day-picker v8 migration
- HotkeysTarget & useHotkeys migration
- PanelStack2 migration
- Table 6.0 changes