react-hook-form / resolvers

📋 Validation resolvers: Yup, Zod, Superstruct, Joi, Vest, Class Validator, io-ts, Nope, computed-types, typanion, Ajv, TypeBox, ArkType, Valibot, effect-ts and VineJS
https://react-hook-form.com/
MIT License
1.67k stars 151 forks source link

Using `useFieldArray`, `shouldUseNativeValidation: true` and `joiResolver` together causes a bug #692

Open ZzzZeta opened 1 month ago

ZzzZeta commented 1 month ago

Describe the bug

TypeError: Cannot read properties of undefined (reading 'refs')

    at i (https://hdv5hj.csb.app/node_modules/
hookform/resolvers/dist/resolvers.js:1:357
    at Object.t [as validateFieldsNatively] (https://hdv5hj.csb.app/node_modules/
hookform/resolvers/dist/resolvers.js:1:431
    at u (https://hdv5hj.csb.app/node_modules/
hookform/resolvers/joi/dist/joi.js:1:688
async Object.R [as _executeSchema]
https://hdv5hj.csb.app/node_modules/react-hook-form/dist/index.cjs.js:1:14139

https://github.com/react-hook-form/resolvers/blob/f7a4fd46af51a2a732c10ed652f5abfa532f4198/src/validateFieldsNatively.ts#L32

field is undefined here.

To Reproduce Steps to reproduce the behavior:

  1. Click on 'APPEND'
  2. Click on 'SUBMIT QUERY'
  3. Click on 'APPEND'
  4. See error

Codesandbox link (Required) https://codesandbox.io/p/sandbox/react-hook-form-joiresolver-hdv5hj

Expected behavior The error should not happen.

Screenshots

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context None.