Merge pull request #26026 from ZhangYiJiang/fix-redux-form-initialize

[redux-form] Add missing properties in InitializeOptions and Reset
This commit is contained in:
Benjamin Lichtman
2018-05-31 15:54:34 -07:00
committed by GitHub
3 changed files with 23 additions and 4 deletions
+1
View File
@@ -20,6 +20,7 @@ export interface ActionTypes {
INITIALIZE: string;
REGISTER_FIELD: string;
RESET: string;
RESET_SECTION: string;
SET_SUBMIT_FAILED: string;
SET_SUBMIT_SUCCEEDED: string;
START_ASYNC_VALIDATION: string;
+17 -4
View File
@@ -84,14 +84,22 @@ export function destroy(...form: string[]): FormAction;
export function focus(form: string, field: string): FormAction;
/**
* Sets the initial values in the form with which future data values will be compared to calculate dirty and pristine.
* The data parameter may contain deep nested array and object values that match the shape of your form fields.
* If the keepDirty parameter is true, the values of the currently dirty fields will be retained to avoid overwriting
* user edits.
* Sets the initial values in the form with which future data values will be compared to calculate dirty and pristine.
*
* If the keepDirty parameter is true, the values of currently dirty fields will be retained to avoid overwriting user edits.
*
* If the keepSubmitSucceeded parameter is true, it will not clear the submitSucceeded flag if it is set.
*
* If the updateUnregisteredFields parameter is true, it will update every initialValue if still pristine instead of only
* registered fields. Highly recommended, defaults to false because of non-breaking backwards compatibility.
*
* If the keepValues parameter is true, it will keep the old values and initial values.
*/
interface InitializeOptions {
keepDirty: boolean;
keepSubmitSucceeded: boolean;
updateUnregisteredFields: boolean;
keepValues: boolean;
}
export function initialize(form: string, data: any, keepDirty?: boolean | InitializeOptions, options?: InitializeOptions): FormAction;
@@ -106,6 +114,11 @@ export function registerField(form: string, name: string, type: FieldType): Form
*/
export function reset(form: string): FormAction;
/**
* Resets the values in the form sections back to the values past in with the most recent initialize action.
*/
export function resetSection(form: string, ...sections: string[]): FormAction;
/**
* Flips the asyncValidating flag true
*/
+5
View File
@@ -518,6 +518,11 @@ export interface StrictFormProps<FormData extends DataShape, P, S> {
*/
reset(): void;
/**
* Resets the form sections to the initialValues. It will be pristine after reset.
*/
resetSection(...sections: string[]) : void;
/**
* Whether or not your form is currently submitting. This prop will only
* work if you have passed an onSubmit function that returns a promise. It