final-form / react-final-form-arrays

A component for rendering and editing arrays 🏁 React Final Form
MIT License
205 stars 70 forks source link

Update peerDependencies to support React 18 #169

Closed bdbvb closed 1 year ago

bdbvb commented 2 years ago

What is the current behavior?

Currently only supports React up to 17.

What is the expected behavior?

Support React 18

(Seems to run OK with 18 - see link below - but causes an error on npm update, unless you use --force)

Sandbox Link

https://codesandbox.io/s/react-final-form-field-arrays-forked-u3z0x6?file=/index.js

What's your environment?

"final-form": "4.20.7" "final-form-arrays": "3.0.2" "react": "18.1.0" "react-dom": "18.1.0" Windows Chrome Node 16.14.0

sudkumar commented 2 years ago

PR #170

bdbvb commented 2 years ago

I still had trouble when manually updating the peer dependency in react-final-form-arrays to include 18.x, so I'm not sure if that's all that has to change.

In the absence of a fix to this repo (which looks to be somewhat abandoned, though I hope it gets picked up again), I looked for a workaround. I first looked at using patch-package (https://www.npmjs.com/package/patch-package), but this isn't well suited for patches to package.json.

I ended up adding the following config in my own package.json file (I'm using react 18.2.0):

"overrides": { "react-final-form-arrays": { "react": "18.2.0" } },

With this, I'm able to dispense with using the --force flag when calling npm install or npm update.

This is a much cleaner workaround for now.

sudkumar commented 2 years ago

I tried patch-packages as well but it is not the right tool so I went with the --legacy-peer-deps.

I didn't know about the override thing. Thank you so much for sharing.

sudkumar commented 2 years ago

I still had trouble when manually updating the peer dependency in react-final-form-arrays to include 18.x, so I'm not sure if that's all that has to change.

BTW, @bdbvb What trouble are you facing after manually updating deps.

If that is the case then, there might be some issue with my application. 😄

Note fields.insert function is already broken.

bdbvb commented 2 years ago

@erikras Is there any plan to upgrade react-final-form-arrays to support React 18?

bdbvb commented 2 years ago

@erikras This was fixed with version 3.1.4 and can be closed.