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 lib] Different objects that are equal by value for proxied hooks objects #159

Closed
ogabrielsantos opened this issue Nov 15, 2020 · 4 comments
Labels
blocked by an issue in another library Waiting for an issue in another library to be solved bug Something isn't working duplicate This issue or pull request already exists

Comments

@ogabrielsantos
Copy link

Describe the bug
First I've reported a issue here but investigating, looks like WDYR says that objects are equal by value when they aren't.

Codesandbox link
https://codesandbox.io/s/react-hook-form-useform-template-forked-rdtej

Steps to reproduce the behavior:

  • Open Codesandbox;
  • Click on LastName input;
  • DON'T Type anything;
  • Leave field;
  • See console log:
  • Firsts logs showing empty errors objects;
  • Then WDYR sayng "different objects that are equal by value.", when they aren't the same;
  • And last log shows the new, changed, error object

Expected behavior
WDYR should not log when props changed by reference and value

@vzaidman vzaidman changed the title Different objects that are equal by value for proxied hooks objects [react-hook-form lib] Different objects that are equal by value for proxied hooks objects Nov 15, 2020
@vzaidman vzaidman added the blocked by an issue in another library Waiting for an issue in another library to be solved label Nov 15, 2020
@vzaidman
Copy link
Collaborator

Ok, the problem is with the library react-hook-form here:
https://github.com/react-hook-form/react-hook-form/blob/master/src/useForm.ts#L409

useState should not be mutated, but this library does it, by changing errors directly which is part of the state.

It's actually a great bug to open on them if it's not open because WDYR is far from being the only thing affected by this bug.

@vzaidman
Copy link
Collaborator

vzaidman commented Nov 15, 2020

bug opened:
react-hook-form/react-hook-form#3455

@vzaidman
Copy link
Collaborator

sadly, this library does something non-standard, so i can't help with it.
I'll try to implement #114 asap so we can turn it off for the library though.

@vzaidman vzaidman reopened this Nov 16, 2020
@vzaidman vzaidman added bug Something isn't working duplicate This issue or pull request already exists labels Nov 16, 2020
@vzaidman
Copy link
Collaborator

will be fixed along with #114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked by an issue in another library Waiting for an issue in another library to be solved bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants