Skip to content

feat(react-form): add display name to components #1491

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/react-form/src/createFormHook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,16 @@ export function createFormHook<
const form = useForm(props)

const AppForm = useMemo(() => {
return (({ children }) => {
const AppForm = (({ children }) => {
return (
<formContext.Provider value={form}>{children}</formContext.Provider>
)
}) as ComponentType<PropsWithChildren>
return AppForm
}, [form])

const AppField = useMemo(() => {
return (({ children, ...props }) => {
const AppField = (({ children, ...props }) => {
return (
<form.Field {...props}>
{(field) => (
Expand All @@ -302,6 +303,7 @@ export function createFormHook<
TSubmitMeta,
TComponents
>
return AppField
}, [form])

const extendedForm = useMemo(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-form/src/useForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export function useForm<
extendedApi.Field = function APIField(props) {
return <Field {...props} form={api} />
}
extendedApi.Subscribe = (props: any) => {
extendedApi.Subscribe = function Subscribe(props: any) {
return (
<LocalSubscribe
form={api}
Expand Down