gpbl / react-day-picker

DayPicker is a customizable date picker component for React. Add date pickers, calendars, and date inputs to your web applications.
https://daypicker.dev
MIT License
6.09k stars 732 forks source link

[bug]: Installation fails of react-day-picker with Nextjs 15 #2559

Closed GeorgeMapili closed 2 weeks ago

GeorgeMapili commented 3 weeks ago

Summary

An error occurs when attempting to install the react-day-picker package in a newly created Next.js 15.0.1 project, due to a dependency conflict with React.

Code

How to reproduce.

1. Create a new Nextjs project
npx create-next-app@latest

2. Select the default options

3. Try to initialize the react-day-picker
npm i react-day-picker

4. The installation fail during the package installation with this following error

npm error ERESOLVE unable to resolve dependency tree
npm error Found: react@19.0.0-rc-69d4b800-20241021
npm error Could not resolve dependency:
npm error peer react@">=16.8.0" from react-day-picker@9.2.0

Environment

Nextjs version: 15.0.1
React version: 19.0.0-rc-69d4b800-20241021,
npm version: 10.8.2
node version: v20.17.0

Expected Behavior

The react-day-picker package should install successfully without dependency conflicts.

Actual Behavior

The installation fails due to a version conflict. react-day-picker@9.2.0 requires a peer dependency of react@">=16.8.0", which does not resolve with the specified React version (19.0.0-rc-69d4b800-20241021) in the Next.js 15.0.1 environment.

gpbl commented 3 weeks ago

👋 @GeorgeMapili, thanks for the report!

The issue is because the installed React version is a release candidate. Why would Next.js install an RC of React and expect maintainers to support it in its peer dependencies? I'm currently busy with other changes.

gunnarrb commented 2 weeks ago

Hi all :). Is there a workaround for this issue until Next.js uses an "official" React build?

GeorgeMapili commented 2 weeks ago

Hello @gunnarrb , As we’re currently utilizing the latest versions of React and Next.js, it’s essential to ensure that all dependencies, including libraries like react-day-picker, remain compatible with these versions and do not revert to React 18 and below.

To enforce this across all packages in the project, we can use the following code block, Add this on package.json

"overrides": {
    "react": "$react",
    "react-dom": "$react-dom"
}

This configuration guarantees that the latest versions of react and react-dom are consistently applied throughout your app.