Skip to content

feature(ReactHookForm): add useFieldProps hook#2375

Draft
ins0 wants to merge 2 commits intomainfrom
feature/custom-field-components
Draft

feature(ReactHookForm): add useFieldProps hook#2375
ins0 wants to merge 2 commits intomainfrom
feature/custom-field-components

Conversation

@ins0
Copy link
Member

@ins0 ins0 commented Mar 11, 2026

These updates make it easier to build custom form fields and manage their props and errors in a consistent way.

Enhancements to field prop management and context:

  • Introduced FieldPropsContext and the useFieldProps hook to provide field props via React context, enabling more composable and reusable custom field components. (useFieldProps.tsx)
  • Updated the Field component to wrap its children with FieldPropsContext, ensuring that child components can access field props from context. (Field.tsx)
  • Refactored type definitions for FieldProps and ForwardedFieldProps to improve type safety and support for custom field components. (Field.tsx)

Type and API improvements:

  • Updated the useUpdateFormDefaultValue hook to support generic field names and provide better type safety. (useUpdateFormDefaultValue.ts)
  • Refactored internal field component prop types for improved flexibility and composability. (useFieldComponent.tsx)

Storybook and documentation:

  • Added a new Storybook story (CustomField.stories.tsx) demonstrating how to build custom field components using the new context and hooks, including error handling and focus management examples.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

Coverage Report for ./packages/components/

Status Category Percentage Covered / Total
🔵 Lines 82.24% 264 / 321
🔵 Statements 82.56% 270 / 327
🔵 Functions 89.85% 62 / 69
🔵 Branches 71.34% 122 / 171
File CoverageNo changed files found.
Generated in workflow #4861 for commit 70d956f by the Vitest Coverage Report Action

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.

1 participant