react-hook-form icon indicating copy to clipboard operation
react-hook-form copied to clipboard

issue: Date with useController is loosing extra properties

Open infodusha opened this issue 8 months ago • 1 comments

Version Number

7.62.0

Codesandbox/Expo snack

https://codesandbox.io/p/devbox/priceless-wing-3knqdk

Steps to reproduce

  1. Go to reproduction URL
  2. Wait 1 sec for onChange to be called
  3. See expected and actual values are different

The issue is probably caused by the cloneObject and the fact that TZDate is extended from Date. However, I find current behaviour confusing since it does not allow to store any decedents of Dates.

Expected behaviour

Value string should be same as expected

What browsers are you seeing the problem on?

No response

Relevant log output


Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

infodusha avatar Aug 18 '25 19:08 infodusha

I may file the PR, we just have to determine the way to fix it.

It seems there is no particular way to clone anything than Date if it was extended. For now I see few solutions:

  1. value[Symbol.for("constructDateFrom")](value); will do the thing, but would work specifically with TZDate
  2. Get rid of cloning overall

infodusha avatar Aug 19 '25 20:08 infodusha