Skip to content

Commit

Permalink
Fix form (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang authored Dec 10, 2019
1 parent e0e76c1 commit a9f9edb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/antd/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const Submit = ({ showLoading, onSubmit, ...props }: ISubmitProps) => {
return (
<Button
type="primary"
htmlType="submit"
onClick={() => form.submit(onSubmit)}
disabled={showLoading ? state.submitting : undefined}
{...props}
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const Submit = ({ showLoading, onSubmit, ...props }: ISubmitProps) => {
return (
<Button
type="primary"
htmlType="submit"
onClick={async() => {
try {
await form.submit(onSubmit)
Expand Down
22 changes: 13 additions & 9 deletions packages/react-schema-renderer/src/hooks/useSchemaForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,21 @@ const useInternalSchemaForm = (props: ISchemaFormProps) => {
const { implementActions } = useEva({
actions
})
const formSchema = useMemo(() => {
const result = new Schema(schema)
implementActions({
getSchema: deprecate(() => result, 'Please use the getFormSchema.'),
getFormSchema: () => result
})
return result
}, [schema])
const registry = getRegistry()
return {
form: useForm(props),
formComponentProps,
formComponentProps:{
...formComponentProps,
...formSchema.getExtendsComponentProps()
},
fields: lowercaseKeys({
...registry.fields,
...fields
Expand All @@ -57,14 +68,7 @@ const useInternalSchemaForm = (props: ISchemaFormProps) => {
formItemComponent: formItemComponent
? formItemComponent
: registry.formItemComponent,
schema: useMemo(() => {
const result = new Schema(schema)
implementActions({
getSchema: deprecate(() => result, 'Please use the getFormSchema.'),
getFormSchema: () => result
})
return result
}, [schema]),
schema: formSchema,
children
}
}
Expand Down

0 comments on commit a9f9edb

Please sign in to comment.