Skip to content

Comments

chore: safely call function methods on elements#13190

Merged
bluebill1049 merged 5 commits intoreact-hook-form:masterfrom
ap0nia:optional-chain-element-methods
Dec 10, 2025
Merged

chore: safely call function methods on elements#13190
bluebill1049 merged 5 commits intoreact-hook-form:masterfrom
ap0nia:optional-chain-element-methods

Conversation

@ap0nia
Copy link
Contributor

@ap0nia ap0nia commented Dec 10, 2025

Proposed Changes

Safely call function methods on elements.

I optimized this locally when I was porting some of the code for my personal project, but I noticed that this optimization could potentially benefit third party integrations.

Fixes # (issue)

I don't think an issue has been opened, but I noticed that AntD noted an issue here.

This minor change should make it easier to plugin "element-like" entities into the library, which may occur when integrating with a UI library.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

@ap0nia ap0nia changed the title chore: optional chain element methods for simpler and safer invocations chore: optional chain element methods Dec 10, 2025
@bluebill1049
Copy link
Member

thanks for the PR, i have avoid optional chain for smaller package size.

@ap0nia
Copy link
Contributor Author

ap0nia commented Dec 10, 2025

Ok got it, makes sense. I switched to using the isFunction utility to check if the method is callable instead of using optional chaining. Now the original max bundle size is preserved! 👍

@ap0nia ap0nia changed the title chore: optional chain element methods chore: safely call function methods on elements Dec 10, 2025
@bluebill1049 bluebill1049 merged commit aa79ac9 into react-hook-form:master Dec 10, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants