modular-forms icon indicating copy to clipboard operation
modular-forms copied to clipboard

React: Peer dependency error with React 19

Open martinliptak opened this issue 1 year ago • 3 comments

I've been following Installation (React) to add Modular Forms into a new React Router 7.1 project with React 19.

npm install @modular-forms/react
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: dependencies@undefined
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^19.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.14.0 || 17.x || 18.x" from @preact/[email protected]
npm ERR! node_modules/@preact/signals-react
npm ERR!   peer @preact/signals-react@"^1.0.0" from @modular-forms/[email protected]
npm ERR!   node_modules/@modular-forms/react
npm ERR!     @modular-forms/react@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

I think the problem is caused by @modular-forms/react depending on @preact/signals-react version 1 which requires react lower than 19. Solution should be upgrading the @preact/signals-react peer dependency to version 2 or 3. Or is there another way around it?

This is related to https://github.com/fabian-hiller/modular-forms/issues/188 and https://github.com/fabian-hiller/modular-forms/pull/191

And thanks for this awesome library! I've read the docs, really like its type-safe API design and can't wait to try it out.

martinliptak avatar Mar 18 '25 08:03 martinliptak

Hey, I am very sorry for this problem. According to our package.json we are using Preact Signals v2. If it is not too complicated we can also upgrade to v3. I plan to rewrite Modular Forms. So I don't plan to spend too much time on the current code.

fabian-hiller avatar Mar 23 '25 15:03 fabian-hiller

Oh, I see, there's a@preact/signals-react@1 peer dependency and another @preact/signals-react@2 dev dependency.

https://github.com/fabian-hiller/modular-forms/blob/main/packages/react/package.json#L68

I managed to successfully add the library using --legacy-peer-deps:

npm install @modular-forms/react --legacy-peer-deps
npm install @preact/signals-react@2 --legacy-peer-deps

But it doesn't seem to be working with React 19. Seeing this error:

The requested module 'react' does not provide an export named '__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED'

I think upgrading to version @preact/signals-react@3 should help (if modular forms can work without automatic tracking).

https://github.com/preactjs/signals/releases/tag/%40preact%2Fsignals-react%403.0.0

martinliptak avatar Mar 24 '25 03:03 martinliptak

probably problem related to integration of @preact/signals-react to react 19 so unfourtunately we moved all project to @tanstack/react-forms

randomizeduser2 avatar Apr 02 '25 21:04 randomizeduser2