ui: [bug]: npx shadcn-ui add calendar fails with React 19 due to react-day-picker@8.10.1 peer dependency conflict
Describe the bug
Describe the bug
npx shadcn@latest add calendar fails due to React 19 compatibility issues with react-day-picker@8.10.1
Error Log
npx shadcn@latest add calendar
✔ Checking registry.
⠇ Installing dependencies.
Something went wrong. Please check the error below for more details.
If the problem persists, please open an issue on GitHub.
Command failed with exit code 1: npm install react-day-picker@8.10.1 date-fns @radix-ui/react-slot
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: undefined@undefined
npm error Found: react@19.1.0
npm error node_modules/react
npm error peer react@">=16.8.0" from @floating-ui/react-dom@2.1.2
npm error node_modules/@floating-ui/react-dom
npm error @floating-ui/react-dom@"^2.0.0" from @radix-ui/react-popper@1.2.4
npm error node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-popper
npm error @radix-ui/react-popper@"1.2.4" from @radix-ui/react-popover@1.1.10
npm error node_modules/@radix-ui/react-popover
npm error @radix-ui/react-popover@"^1.1.10" from the root project
npm error @floating-ui/react-dom@"^2.0.0" from @radix-ui/react-popper@1.2.2
npm error node_modules/@radix-ui/react-popper
npm error @radix-ui/react-popper@"1.2.2" from @radix-ui/react-menu@2.1.6
npm error node_modules/@radix-ui/react-menu
npm error @radix-ui/react-menu@"2.1.6" from @radix-ui/react-dropdown-menu@2.1.6
npm error node_modules/@radix-ui/react-dropdown-menu
npm error 1 more (@radix-ui/react-tooltip)
npm error 1 more (@radix-ui/react-popper)
npm error peer react@"^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" from @inertiajs/react@2.0.3
npm error node_modules/@inertiajs/react
npm error @inertiajs/react@"^2.0.3" from the root project
npm error 104 more (@radix-ui/react-alert-dialog, ...)
npm error
npm error Could not resolve dependency:
npm error react-day-picker@"8.10.1" from the root project
npm error
npm error Conflicting peer dependency: react@18.3.1
npm error node_modules/react
npm error peer react@"^16.8.0 || ^17.0.0 || ^18.0.0" from react-day-picker@8.10.1
npm error node_modules/react-day-picker
npm error react-day-picker@"8.10.1" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
### Affected component/components
Calendar
### How to reproduce
1. Fresh React 19 project
2. Run npx shadcn-ui@latest add calendar
3. See dependency conflict error
### Codesandbox/StackBlitz link
_No response_
### Logs
```bash
System Info
System: macOS
npm -v: 10.8.1
node -v: v20.16.0
Before submitting
- I’ve made research efforts and searched the documentation
- I’ve searched for existing issues
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 16
Commits related to this issue
- fix: Change calendar to work with updated daypicker Code to update the calendar from: https://github.com/shadcn-ui/ui/issues/7258 — committed to James-Makela/budgit by James-Makela 2 years ago
- 🐛 버전 충돌 수정 react-day-picker 업데이트, 레이아웃 망가지는거 수정 (https://github.com/shadcn-ui/ui/issues/7258) — committed to oz-co-project-3/oz-co-project-3_frontend by Nagi-ei 2 years ago
use this for latest version
Hi,
I had the same issue, but after updating to the latest version it works now. I was using date-fns directly for other functions, although it’s not strictly necessary (https://daypicker.dev/changelog#whats-new)
"date-fns": "^4.1.0", "react-day-picker": "^9.6.7", "react": "19.1.0",However, I’m now facing a small visual issue — please take a look.
Thanks!
### With some style adjustments
This should be updated officially. Works great, thanks.
use this
Yes after updating manually it theoretically works but the problem is since react-day-picker library changed so much it corrupts the layout of the calendar. Even if you check the calendar.tsx component there are errors highlighted.
Hello @TharukaDananjaya, I would like to work on this issue.
The issue here is a compatibility issue between react 19 and the react-day-picker package (version 8.10.1) that shadcn-ui’s calendar component depends on.
If assigned this issue, I will ensure compliance with the project’s guidelines.
ETA
Fixed https://ui.shadcn.com/docs/components/calendar#upgrade-guide
thanks for these solution