Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add reset render prop

dominik-zeglen4beb5d86af0c
diff --git a/saleor/static/dashboard-next/components/Form/Form.tsx b/saleor/static/dashboard-next/components/Form/Form.tsx
index 5a87b5aaff..5b7dba2d1b 100644
--- a/saleor/static/dashboard-next/components/Form/Form.tsx
+++ b/saleor/static/dashboard-next/components/Form/Form.tsx
@@ -7,6 +7,7 @@ export interface FormProps<T extends {}> {
hasChanged: boolean;
errors: { [key: string]: string };
change(event: React.ChangeEvent<any>, cb?: () => void);
+ reset();
submit(event?: React.FormEvent<any>);
}) => React.ReactElement<any>;
errors?: UserError[];
@@ -151,6 +152,10 @@ class FormComponent<T extends {} = {}> extends React.Component<
)
: {},
hasChanged: this.hasChanged(),
+ reset: () =>
+ this.setState({
+ fields: this.state.initial
+ }),
submit: this.handleSubmit
});