Skip to content

Instantly share code, notes, and snippets.

@kristian-puccio
Created July 7, 2016 23:45
Show Gist options
  • Save kristian-puccio/65d32833306ba8b697b1b3db041aeb44 to your computer and use it in GitHub Desktop.
Save kristian-puccio/65d32833306ba8b697b1b3db041aeb44 to your computer and use it in GitHub Desktop.
// @flow
import React from 'react';
declare module 'redux-form' {
declare type InputProps = {
active: boolean,
touched: boolean,
error: ?string,
input: {
name: string,
placeholder?: ?string,
label?: string,
value: ?string|number,
type?: string,
},
};
declare type FormProps = {
active: string,
asyncValidate: (values: Object, dispatch: Function, props: Object) => Promise<void>,
asyncValidating: string | boolean,
destroyForm: Function,
dirty: boolean,
error: string,
handleSubmit: (data: { [field: string]: string }) => void | Promise<any>,
initializeForm: (data:Object) => any,
invalid: boolean,
pristine: boolean,
resetForm: Function,
formKey: string,
submitting: boolean,
submitFailed: boolean,
touch: (...fields: Array<string>) => void,
touchAll: () => void,
untouch: (...fields: Array<string>) => void,
untouchAll: () => void,
valid: boolean,
values: Object
};
declare type FormConfig = {
form?: string,
alwaysAsyncValidate?: boolean,
asyncBlurFields?: Array<string>,
asyncValidate?: (values: Object, dispatch: Function, props: Object) => Promise<void>,
destroyOnUnmount?: boolean,
formKey?: string,
getFormState?: (state: Object, reduxMountPoint: string) => mixed,
initialValues?: { [field: string]: string },
onSubmit?: Function,
onSubmitFail?: Function,
onSubmitSuccess?: Function,
verwriteOnInitialValuesChange?: boolean,
propNamespace?: string,
readonly?: boolean,
reduxMountPoint?: String,
returnRejectedSubmitPromise?: boolean,
touchOnBlur?: boolean,
touchOnChange?: boolean,
validate?: (values:Object, props:Object) => Object
};
declare function reducer(state: any, action: Object): any;
declare type FieldProps = {
name: string,
placeholder?: ?string,
label?: string,
value?: ?string|number,
type?: string,
component: React.Component<InputProps>,
};
declare function Field(props: FieldProps): React.Component<InputProps>;
declare function reduxForm(config: FormConfig, mapStateToProps?: Function, mapDispatchToProps?: Function, mergeProps?: any, options?: Object): (component: React.Component<*>) => React.Component;
declare function SubmissionError(err: Object): Object;
declare function reset(formName: string): Object;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment