Skip to content

Commit 4b43a5c

Browse files
DovydasNavickasMartynas Žilinskas
authored andcommitted
Form onMount callback implemented. (#93)
* Form onMount callback implemented.
1 parent c4233d5 commit 4b43a5c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

packages/simplr-forms/src/abstractions/base-form.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ export abstract class BaseForm<TProps extends FormContracts.FormProps, TState> e
5454
}
5555
}
5656

57+
public componentDidMount(): void {
58+
const props: TProps = this.props;
59+
if (props.onMount != null) {
60+
props.onMount(this.FormStore);
61+
}
62+
}
63+
5764
abstract render(): JSX.Element | null;
5865

5966
/*

packages/simplr-forms/src/contracts/form.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { FormStore } from "../stores/form-store";
44
import { FormErrorRecord } from "./error";
55
import { FieldValidationType } from "./validation";
66

7+
export type FormOnMountCallback = (store: FormStore) => void;
8+
79
export interface FormProps {
810
formId?: string;
911
formStore?: FormStore;
@@ -12,6 +14,7 @@ export interface FormProps {
1214
disabled?: boolean;
1315
fieldsValidationType?: FieldValidationType;
1416
formValidationType?: FieldValidationType;
17+
onMount?: FormOnMountCallback;
1518
}
1619

1720
export type FormStateProps = FormProps & React.Props<any>;

0 commit comments

Comments
 (0)