Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react hook form throwing TypeError: Cannot read properties of undefined (reading 'next') ar remove and reset of useForm #10021

Closed
sharanyam123 opened this issue Feb 28, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@sharanyam123
Copy link

sharanyam123 commented Feb 28, 2023

Hi,
I am facing the issue with react-hook-form useForm 'remove' and 'reset' as of now. It was working fine before but facing issue from today.
Its throwing TypeError: Cannot read properties of undefined (reading 'next')
This is the issue:

for test cases:

<AccountForm /> › removePopup
    TypeError: Cannot read property 'next' of undefined
      288 |     if(obj?.id !== -1){
      289 |       response = await removeVmImage(props.accountId, obj?.id);
    > 290 |       response?.status === 204 && remove(index)
          |                                  ^
      291 |       const message = response?.status !== 204 ? {data: response?.detail , status : "error"} : {data:`${obj?.imageName} deleted
successfully`, status : "success"}
      292 |       props.handleSaveSnackbar(message)
      293 |     }
      at Object.isValid [as next] (../../node_modules/react-hook-form/src/utils/createSubject.ts:49:5)
      at Object.options [as _updateFieldArray] (../../node_modules/react-hook-form/src/logic/createFormControl.ts:232:29)
      at remove (../../node_modules/react-hook-form/src/useFieldArray.ts:206:5)
      at deleteVmImage (components/ProjectDetails/Account/AccountDetails/AccountForm/AccountForm.tsx:290:35)

for UI: when we use remove or reset

image

versions:
next: 12.0.7
react:17.0.2
react-hook-form:7.28.0

@bluebill1049
Copy link
Member

#2848

@bluebill1049 bluebill1049 added the status: need more detail Please follow our issue template. label Mar 1, 2023
@bluebill1049
Copy link
Member

bluebill1049 commented Mar 1, 2023

Any update on this issue with a reproducible codesandbox and steps to reproduce? (version number and etc...)

@bluebill1049
Copy link
Member

I have found the root cause and will patch this today, however, please consider following the issue template. This is helping me and everyone else who are using this software.

bluebill1049 added a commit that referenced this issue Mar 1, 2023
@bluebill1049 bluebill1049 added bug Something isn't working and removed status: need more detail Please follow our issue template. labels Mar 1, 2023
bluebill1049 added a commit that referenced this issue Mar 1, 2023
…10026)

* attempt to fix cypress action

* Revert "attempt to fix cypress action"

This reverts commit e84e19f.

* fix by change node version

* rename _stateFlags to _state

* try node 17

* Revert "try node 17"
asdasdahhhhhkl

This reverts commit 9a3b223.

* remove version fix

* wait for vite

* Revert "📦 fix cypress tests (#10025)"

This reverts commit ba919be.

* Revert "Revert "📦 fix cypress tests (#10025)""

This reverts commit 9057da6.

* Revert "Revert "Revert "📦 fix cypress tests (#10025)"""

This reverts commit 11ba329.

* fix #10021
@florian-gierlichs
Copy link

Thank you for looking into it. I still get the error with the new patch version.

In my case, the form is in a modal. In case of an error in the form, where I close the modal and the component unmounts the error appears. So I guess there is some promise unhandled

@bluebill1049
Copy link
Member

@florian-gierlichs would be good to reproduce it in a codesandbox, and happy to look into and fix that.

@maidi29
Copy link

maidi29 commented Mar 3, 2023

@bluebill1049 thanks for fixing :) Is it possible to publish the new version in npm? There is still 7.43.3

@bluebill1049
Copy link
Member

@maidi29 published 🤘

@florian-gierlichs
Copy link

@bluebill1049 nvm 7.43.4 seem to work nice.
thank you for your work buddy!

@MarcinJarowski
Copy link

Any tips on how to fix that without upgrading a version of RHF? I need to fix that in one place and I don't want to upgrade the whole environment.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants