add submit method to Form (#37979)

This commit is contained in:
Patrik
2019-09-05 10:42:36 -07:00
committed by Andrew Casey
parent 83e5c8c944
commit c2541878ec
2 changed files with 15 additions and 1 deletions
+3 -1
View File
@@ -56,7 +56,9 @@ declare module 'react-jsonschema-form' {
acceptcharset?: string;
}
export default class Form<T> extends React.Component<FormProps<T>> {}
export default class Form<T> extends React.Component<FormProps<T>> {
submit: () => void;
}
export type UiSchema = {
'ui:field'?: Field | string;
@@ -173,3 +173,15 @@ export const withThemeExample = () => {
export const additionalPropertyFlagExample = () => {
return ADDITIONAL_PROPERTY_FLAG;
};
export const ExternalFormSubmissionExample = () => {
const formRef = React.useRef<Form<any>>(null);
return (
<Form schema={schema} ref={formRef}>
<button onClick={formRef.current ? formRef.current.submit : undefined}>
FancySubmitButton
</button>
</Form>
);
};