"isValid" does not work in "production" mode correctly for "useFieldArray"
Describe the bug
isValid
from formState
behaves itself differently for dev
mode and production
build by using useFieldArray
dev
mode is launched byreact-scripts start
production
mode is built byreact-scripts build
and served by any server. In my example it'sexpress
server
To Reproduce Steps to reproduce the behavior:
- Please clone the git repo with reproducible scenarios:
- Make
npm install
- Run
npm run dev:make-build-and-serve:run
First test-case
- Go to
localhost:8001
and check thatisValid: false
is shown on the bottom of page. - Enter any
Quantity
andProduct ID
forHeading
section.isValid
label will be changed totrue
- Delete
Quantity
orProduct ID
.isValid
label will be changed tofalse
- Validation will be shown under the fieldname
- Select
Heading2
. FirstHeading
will be closed and inputs should be unmounted from DOM. - Enter any
Quantity
andProduct ID
forHeading2
section.isValid
label is still equalfalse
.
If you perform the same scenario but for dev
mode (npm start
), on the 6
step isValid
will be changed to true
Second test-case
- Go to
localhost:8001
and check thatisValid: false
is shown on the bottom of page. - Enter
Quantity
ORProduct ID
forHeading
section. Second field must be empty. - Select
Heading2
. FirstHeading
will be closed and inputs should be unmounted from DOM. - Enter any
Quantity
andProduct ID
forHeading2
section.isValid
label is still equalfalse
.
If you perform the same scenario but for dev
mode (npm start
), on the 4
step isValid
will be changed to true
Codesandbox link (Required)
Codesandbox:
Please make sure that you go to the Deployment
section and made a production
build and deployed it to Netlify
Then please click Visit Site
link
Expected behavior
isValid
must behave itself equally forproduction
anddev
builds.- For
production
buildisValid
must behave itself equally how it works fordev
build.
Desktop (please complete the following information):
- Windows 10 / Ubuntu / OS:
- Browser Chrome / Firefox / Safari
- Version 88.0.4324.150 / 85.0 / 13.1 (15609.1.20.111.8)
Smartphone (please complete the following information):
- was not tested
Additional context
This issue is reproducible only by using useFieldArray
isDirty
and other flags are also affected