Closed
Description
Version Number
7.51.3
Codesandbox/Expo snack
https://codesandbox.io/p/sandbox/thirsty-goldstine-n9rfhv?file=%2Fsrc%2FApp.tsx
Steps to reproduce
- Go to codesandbox example
- Type "message" into input
- Click "switch pattern" button
- Type "message" into input
- See error

Problem here is that after click on "switch pattern" I start to provide rules = {{ required: true }}
property to controller without any explicit undefined
for rules.pattern and Controller use "cached" value from previous rules
property value
Workaround 1
rules={{
...rulesToUse,
pattern: rulesToUse.pattern,
}}
Workaround 2
const rules2 = {
// pattern: undefined, <---- uncomment this line
required: true,
};
P.S. I didn't try to catch same behaviour with register({rules})
maybe it's not a Controller specific behaviour
Expected behaviour
I expect that change of "rules" property will update rules.pattern property as well without explicit "undefined"
What browsers are you seeing the problem on?
Chrome
Relevant log output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
No labels