Skip to content

Commit

Permalink
fix(antd/next): remove RecordScope (#3726)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZirkleTsing authored Feb 17, 2023
1 parent 75d36d2 commit 29c347a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 32 deletions.
30 changes: 14 additions & 16 deletions packages/antd/src/form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,21 @@ export const Form: React.FC<React.PropsWithChildren<FormProps>> = ({
}) => {
const top = useParentForm()
const renderContent = (form: FormType | ObjectField) => (
<RecordScope getRecord={() => (isForm(form) ? form.values : form.value)}>
<PreviewText.Placeholder value={previewTextPlaceholder}>
<FormLayout {...props}>
{React.createElement(
component,
{
onSubmit(e: React.FormEvent) {
e?.stopPropagation?.()
e?.preventDefault?.()
form.submit(onAutoSubmit).catch(onAutoSubmitFailed)
},
<PreviewText.Placeholder value={previewTextPlaceholder}>
<FormLayout {...props}>
{React.createElement(
component,
{
onSubmit(e: React.FormEvent) {
e?.stopPropagation?.()
e?.preventDefault?.()
form.submit(onAutoSubmit).catch(onAutoSubmitFailed)
},
props.children
)}
</FormLayout>
</PreviewText.Placeholder>
</RecordScope>
},
props.children
)}
</FormLayout>
</PreviewText.Placeholder>
)
if (form)
return <FormProvider form={form}>{renderContent(form)}</FormProvider>
Expand Down
30 changes: 14 additions & 16 deletions packages/next/src/form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,21 @@ export const Form: React.FC<React.PropsWithChildren<FormProps>> = ({
}, [lang])

const renderContent = (form: FormType | ObjectField) => (
<RecordScope getRecord={() => (isForm(form) ? form.values : form.value)}>
<PreviewText.Placeholder value={previewTextPlaceholder}>
<FormLayout {...props}>
{React.createElement(
component,
{
onSubmit(e: React.FormEvent) {
e?.stopPropagation?.()
e?.preventDefault?.()
form.submit(onAutoSubmit).catch(onAutoSubmitFailed)
},
<PreviewText.Placeholder value={previewTextPlaceholder}>
<FormLayout {...props}>
{React.createElement(
component,
{
onSubmit(e: React.FormEvent) {
e?.stopPropagation?.()
e?.preventDefault?.()
form.submit(onAutoSubmit).catch(onAutoSubmitFailed)
},
props.children
)}
</FormLayout>
</PreviewText.Placeholder>
</RecordScope>
},
props.children
)}
</FormLayout>
</PreviewText.Placeholder>
)

if (form)
Expand Down

0 comments on commit 29c347a

Please sign in to comment.