Skip to content

Commit 9afa7c0

Browse files
authored
fix(react-form): add display name to components for better debugging (#1491)
* feat(react-form): add `displayName` to `<AppForm>` & `<AppField>` * Stop assigning `.displayName` * Add name to `<Subscribe>`
1 parent 9a3368f commit 9afa7c0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/react-form/src/createFormHook.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,16 @@ export function createFormHook<
270270
const form = useForm(props)
271271

272272
const AppForm = useMemo(() => {
273-
return (({ children }) => {
273+
const AppForm = (({ children }) => {
274274
return (
275275
<formContext.Provider value={form}>{children}</formContext.Provider>
276276
)
277277
}) as ComponentType<PropsWithChildren>
278+
return AppForm
278279
}, [form])
279280

280281
const AppField = useMemo(() => {
281-
return (({ children, ...props }) => {
282+
const AppField = (({ children, ...props }) => {
282283
return (
283284
<form.Field {...props}>
284285
{(field) => (
@@ -302,6 +303,7 @@ export function createFormHook<
302303
TSubmitMeta,
303304
TComponents
304305
>
306+
return AppField
305307
}, [form])
306308

307309
const extendedForm = useMemo(() => {

packages/react-form/src/useForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export function useForm<
193193
extendedApi.Field = function APIField(props) {
194194
return <Field {...props} form={api} />
195195
}
196-
extendedApi.Subscribe = (props: any) => {
196+
extendedApi.Subscribe = function Subscribe(props: any) {
197197
return (
198198
<LocalSubscribe
199199
form={api}

0 commit comments

Comments
 (0)