Skip to content

Commit 73ff84a

Browse files
authored
Merge pull request #5809 from marmelab/form-with-redirect-types
Extract and Export FormWithRedirect Types
2 parents 3bba105 + 963f0b4 commit 73ff84a

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

packages/ra-core/src/form/FormWithRedirect.tsx

+14-11
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,24 @@ const FormWithRedirect: FC<FormWithRedirectProps> = ({
153153
export type FormWithRedirectProps = FormWithRedirectOwnProps &
154154
Omit<FormProps, 'onSubmit' | 'active'>;
155155

156+
export type FormWithRedirectRender = (
157+
props: Omit<FormViewProps, 'render' | 'setRedirect'>
158+
) => React.ReactElement<any, any>;
159+
160+
export type FormWithRedirectSave = (
161+
data: Partial<Record>,
162+
redirectTo: RedirectionSideEffect,
163+
options?: {
164+
onSuccess?: (data?: any) => void;
165+
onFailure?: (error: any) => void;
166+
}
167+
) => void;
156168
export interface FormWithRedirectOwnProps {
157169
defaultValue?: any;
158170
record?: Record;
159171
redirect?: RedirectionSideEffect;
160-
render: (
161-
props: Omit<FormViewProps, 'render' | 'setRedirect'>
162-
) => React.ReactElement<any, any>;
163-
save?: (
164-
data: Partial<Record>,
165-
redirectTo: RedirectionSideEffect,
166-
options?: {
167-
onSuccess?: (data?: any) => void;
168-
onFailure?: (error: any) => void;
169-
}
170-
) => void;
172+
render: FormWithRedirectRender;
173+
save?: FormWithRedirectSave;
171174
sanitizeEmptyValues?: boolean;
172175
saving?: boolean;
173176
version?: number;

packages/ra-core/src/form/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import FormContext from './FormContext';
77
import FormField from './FormField';
88
import FormWithRedirect, {
99
FormWithRedirectProps,
10+
FormWithRedirectRender,
11+
FormWithRedirectSave,
1012
HandleSubmitWithRedirect,
1113
} from './FormWithRedirect';
1214
import useInput, { InputProps, UseInputValue } from './useInput';
@@ -29,6 +31,8 @@ export type {
2931
FormDataConsumerRender,
3032
FormDataConsumerRenderParams,
3133
FormWithRedirectProps,
34+
FormWithRedirectRender,
35+
FormWithRedirectSave,
3236
HandleSubmitWithRedirect,
3337
InputProps,
3438
UseInputValue,

0 commit comments

Comments
 (0)