Skip to content

Conversation

kapral18
Copy link
Contributor

@kapral18 kapral18 commented Jul 21, 2021

useField public handlers like onFocus, onChange, onBlur are changing their identities based on various internal variables and externally available props/(config parts) like value, name, parse etc...

I am suggesting that public handlers should not be subject to identity change at all, so that consumers can rely on those without jumping through hoops with useRef as in https://reactjs.org/docs/hooks-faq.html#what-can-i-do-if-my-effect-dependencies-change-too-often.

As a consequence after this change consumer code relying on this behavior might break, hence this is a BREAKING CHANGE

Closes #816

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 21, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 057c7a2:

Sandbox Source
🏁 React Final Form - Third Party Components Example Issue #816

BREAKING:
onBlur, onChange, onFocus handlers no longer change identity
if props or internal state is changed,
thus on consumer side the behavior relying on handler identity can break

Closes #816
@erikras erikras merged commit b634ace into final-form:main Jul 22, 2021
@erikras
Copy link
Member

erikras commented Sep 29, 2021

Published in v6.5.4.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

input.onChange has a new reference each time value changes
2 participants