Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OnSubmit and OnError callback to index.d.ts #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ export interface FieldProps {
export class Field extends React.Component<FieldProps, any> {
}

export type OnSubmitCallback = (s: {name: string, values: {[key: string]: any}}) => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be simplified with values: object.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can imagine it as type object = {[key: string]: any}}, therefore yes, it's better 'cause it's former and shorter.

export type OnErrorCallback = (e: {name: string, errors: {[key: string]: any}}) => void;

export interface FormProps {
method?: "POST" | "GET" | "PUT" | "DELETE";
name: String | string;
onError?: (e: {name: string, errors: {[key: string]: any}}) => void;
onSubmit?: (s: {name: string, values: {[key: string]: any}}) => void;
onError?: OnErrorCallback;
onSubmit?: OnSubmitCallback;
validations?: {[key: string]: Validation[]};
}

Expand Down